Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Page 1 of 2 12 LastLast
Results 1 to 15 of 28
  1. #1
    New Coder
    Join Date
    Sep 2010
    Posts
    69
    Thanks
    8
    Thanked 0 Times in 0 Posts

    Php mail not working anymore - no error message

    So I've been using php mail() for a while now to send out an email notification to a mailing list located in mysql everytime a newsletter is uploaded to the same database.

    For some reason it is not working anymore, but I'm not getting any error message and still receive the success message confirming the emails were sent after uploading a newsletter. The emailing list in mysql has over 400 emails, so I'm wondering if that has something to do with it...
    Any help would be appreciated, here's my code, it runs after the code to upload the newsletter

    PHP Code:
    <?php
    mysql_connect
    ("servername""dbusername""dbpassword") or die(mysql_error()); 
    mysql_select_db("dbname") or die(mysql_error()); 
    $result mysql_query("SELECT email FROM email_list") or die(mysql_error());
                
    while (
    $row mysql_fetch_array($resultMYSQL_ASSOC)) { 
    $email$row['email'];
    if(isset(
    $_POST['upload'])){
        if(
    $goodtogo =="alliswell"){
            
    $headers "From: email@email.com\r\nContent-type: text/html"

    $message "<html><body><center>
    <table border='0' bgcolor='#8a6754' width='850'>
    <tr><td align='center'><img src='http://website.com/images/logo.png'></td></tr>
    <tr><td align='center'><font color='#ffffff' face='Arial'>The newsletter for website.com has been updated. To view it, <a href='http://website.com/newsletter.php'>click here</a><br><br><br>


    <em>Adobe Acrobat Reader is needed to view this newsletter. To download this free software click the link below</em><br>

    http://get.adobe.com/reader<br><br>

    </font></td></tr>
    </center></body>
    </html>"
    ;

    $mailmail("$email""Subject"$message$headers);

    }}}
    echo 
    "<font color='#ffffff'><br><em>A notification was successfully sent to the mailing list.<br></em></font>";
    ?>

  • #2
    God Emperor Fou-Lu's Avatar
    Join Date
    Sep 2002
    Location
    Saskatoon, Saskatchewan
    Posts
    16,987
    Thanks
    4
    Thanked 2,660 Times in 2,629 Posts
    There's no confirmation that the mail was queued.
    You need to contain the results of the mail. If its ever false, something went wrong with the queue.
    I'd add a $bResult to it. Default it to true. If $mail is ever false, set $bResult to false.
    After the loop, check what $bResult is. If its false, one or more mail() failed. If you want more data, you can use an array of $mail to track results of each one.

    If these register successful, the problem is not with PHP, but with SMTP configuration or machine security.

  • #3
    New Coder
    Join Date
    Sep 2010
    Posts
    69
    Thanks
    8
    Thanked 0 Times in 0 Posts
    $bResult was returned false after the mail function, but how do I go about building an array to tell what the problem was?

  • #4
    God Emperor Fou-Lu's Avatar
    Join Date
    Sep 2002
    Location
    Saskatoon, Saskatchewan
    Posts
    16,987
    Thanks
    4
    Thanked 2,660 Times in 2,629 Posts
    Quote Originally Posted by KatieK View Post
    $bResult was returned false after the mail function, but how do I go about building an array to tell what the problem was?
    PHP Code:
    $aResult = array();
    .....

    $aResult[] = mail(....); 
    $aResult will be an array with each entry added numerically. You could add an associative offset for something like the address.
    Chances are, if one returns false, they all return false. Sounds like the sendmail may not be configured properly, so you'll need to contact your host.

    Edit:
    BTW, you can never be sure of the problem with mail() from PHP. All you can tell is if it queued or not with the sendmail program in use. If its successful, it has queued, otherwise it has failed. Beyond what PHP can do, its the sendmail's job to actually send the email, and PHP has no way to determine if that was successful from the mail() function.

  • Users who have thanked Fou-Lu for this post:

    KatieK (04-17-2012)

  • #5
    New Coder
    Join Date
    Sep 2010
    Posts
    69
    Thanks
    8
    Thanked 0 Times in 0 Posts
    How do I know what sendmail program I'm using though?

    Any ideas why this would become a problem all of the sudden when everything has worked fine for so long?

  • #6
    God Emperor Fou-Lu's Avatar
    Join Date
    Sep 2002
    Location
    Saskatoon, Saskatchewan
    Posts
    16,987
    Thanks
    4
    Thanked 2,660 Times in 2,629 Posts
    If you're hosting your own server, you can check the sendmail using the command line or gui tools. If your on windows, it'll be a separate program that requires configuring with php.ini to configure the proper smtp ports.
    If you ar ehosted, contact your host to inform them sendmail doesn't appear to be working. Its possible that they have altered the sendmail path without updating ini, or changed how you are to send email.

  • #7
    New Coder
    Join Date
    Sep 2010
    Posts
    69
    Thanks
    8
    Thanked 0 Times in 0 Posts
    I'm waiting to hear back from our host concerning php mail settings, but I noticed that when I try to use this form on a different computer I get an actual php error. Says 'No recipient addresses found in header'. But when I echo the $email variable the emails do display so I'm not sure what its referring to...

    Any ideas?



    Heard back from our host and I guess the problem is we reached the max for emails we could send out per day which is 1000. thanks for your help
    Last edited by KatieK; 04-18-2012 at 11:16 PM.

  • #8
    New Coder
    Join Date
    Sep 2010
    Posts
    69
    Thanks
    8
    Thanked 0 Times in 0 Posts
    Sorry to keep reopening this but we found out the problem we had isn't resolved. Even when we're within the 1000 relays/day limits the php mail isn't working. We receive the message saying 'No recipient addresses found in header'.

    Any ideas on why this error would suddenly pop up when it's been working fine for months and what we can do to make it work again?

  • #9
    God Emperor Fou-Lu's Avatar
    Join Date
    Sep 2002
    Location
    Saskatoon, Saskatchewan
    Posts
    16,987
    Thanks
    4
    Thanked 2,660 Times in 2,629 Posts
    Consistently or periodically?
    Periodically would indicate that the problem is with your data; in particular that the email address doesn't exist (I think the error for malformed is different). If its a matter of having empty email addresses, I'd address the cause of the empty email addresses, but a temporary solution would be to add a where clause indicating NOT email IS NULL and email <> ""

  • #10
    New Coder
    Join Date
    Sep 2010
    Posts
    69
    Thanks
    8
    Thanked 0 Times in 0 Posts
    We've never had this problem before, but I did notice there are some empty email addresses. They've been there a while though and didn't cause any problems before. I will try limiting results to only emails that aren't blank and see if that does anything.

  • #11
    Senior Coder
    Join Date
    Feb 2011
    Location
    Your Monitor
    Posts
    4,327
    Thanks
    60
    Thanked 525 Times in 512 Posts
    Blog Entries
    4
    Quote Originally Posted by KatieK View Post
    We've never had this problem before, but I did notice there are some empty email addresses. They've been there a while though and didn't cause any problems before. I will try limiting results to only emails that aren't blank and see if that does anything.
    That indicates that your php configuration has changed and previously you simply didn't know that you had mail failures for individual addresses.
    See my new CodingForums Blog: http://www.codingforums.com/blogs/tangoforce/

    Many useful explanations and tips including: Cannot modify headers - already sent, The IE if (isset($_POST['submit'])) bug explained, unexpected T_CONSTANT_ENCAPSED_STRING, debugging tips and much more!

  • #12
    New Coder
    Join Date
    Sep 2010
    Posts
    69
    Thanks
    8
    Thanked 0 Times in 0 Posts
    I'm not able to test this out yet as we have to wait 24hr for our max relays to reset, will be able to in a couple hours.

    The thing is I'm pretty sure the blank email fields in the database aren't the problem because they've been there a while and the problem just now started showing up. And it's not that there's mail failures for only the emails that are empty, none of them are sending out.

  • #13
    God Emperor Fou-Lu's Avatar
    Join Date
    Sep 2002
    Location
    Saskatoon, Saskatchewan
    Posts
    16,987
    Thanks
    4
    Thanked 2,660 Times in 2,629 Posts
    Quote Originally Posted by KatieK View Post
    I'm not able to test this out yet as we have to wait 24hr for our max relays to reset, will be able to in a couple hours.

    The thing is I'm pretty sure the blank email fields in the database aren't the problem because they've been there a while and the problem just now started showing up. And it's not that there's mail failures for only the emails that are empty, none of them are sending out.
    If no emails are sending, why are you waiting for the max daily sends to reset?

  • #14
    New Coder
    Join Date
    Sep 2010
    Posts
    69
    Thanks
    8
    Thanked 0 Times in 0 Posts
    Because apparently even if we try to send emails out and they don't go through it still counts towards our relays.

  • #15
    God Emperor Fou-Lu's Avatar
    Join Date
    Sep 2002
    Location
    Saskatoon, Saskatchewan
    Posts
    16,987
    Thanks
    4
    Thanked 2,660 Times in 2,629 Posts
    I'd be demanding a full explanation out of your host. If they are counting non-sent emails it would be time to find a new host.
    Also, how do you know that the emails have not been sent?


  •  
    Page 1 of 2 12 LastLast

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •