#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Dec 2003
    Posts
    9
    Rep Power
    0

    php mail() fn - no mail being sent, no errors, no log, nothing!


    I am using a VERY simple script to attempt to send mail using php's built in mail() function.

    <snip>
    <?
    $mail_msg = "thank you for your order\r\n";

    $email = "scowby@yahoo.com";
    $subject = "testing php mail\r\n";
    $from = "scowby@yahoo.com";

    echo "sending mail<br>\n";
    $rc = mail($email, $subject, $mail_msg, $from);
    echo "mail sent to $email. rc=$rc\n";
    ?>

    This script will run for about 2 minutes, and then come back with rc=1. However, there is no e-mail being sent (or none received, rather).

    I *believe* the source of the problem is with sendmail, but have no idea where to look, or how really to troubleshoot sendmail - where to look for error logs,etc.

    Any thoughts on how I can get more information on this problem? Like I said, my only response from this script is a long delay and then a 'true' return code from the mail() function.

    It also appears that I cannot even send mail using the 'mail' command from the command line. It asks for a recipient and I type in a message and type a '.' to end the message. Everything seems to work Ok, I'm just not getting e-mail at the destination.

    Is there any logfile for sendmail, or any way to track the flow of information on my machine?

    Oh yea, I'm running RedHat Linux 8.0.

    Thanks in advance!
  2. #2
  3. Full Access
    Devshed Regular (2000 - 2499 posts)

    Join Date
    Jun 2000
    Location
    London, UK
    Posts
    2,019
    Rep Power
    21
    This script will run for about 2 minutes, and then come back with rc=1. However, there is no e-mail being sent (or none received, rather).
    Check your sendmail logs -- /var/log/maillog
    I *believe* the source of the problem is with sendmail, but have no idea where to look, or how really to troubleshoot sendmail - where to look for error logs,etc.
    See above -- Sendmail logs its activity to /var/log/maillog
    It also appears that I cannot even send mail using the 'mail' command from the command line. It asks for a recipient and I type in a message and type a '.' to end the message. Everything seems to work Ok, I'm just not getting e-mail at the destination.
    /var/log/maillog should give you a hint as to what's going wrong.
    Oh yea, I'm running RedHat Linux 8.0.
    The version of sendmail that ships with RedHat 8 is broken in several ways. After attempting to fix this for several days at work, I uninstalled sendmail and installed qmail instead. It's worked fine ever since.
    Alex
    (http://www.alex-greg.com)
  4. #3
  5. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Dec 2003
    Posts
    9
    Rep Power
    0
    Ok, this is what maillog is printing (initially):

    Dec 17 15:56:58 leosol sendmail[1789]: hBHKuwAT001789: from=apache, size=91, class=0, nrcpts=1, msgid=<200312172056.hBHKuwAT001789@leosol.com>, relay=apache@localhost


    And then, after a bit (and this message keeps getting printed every so often - i.e. maillog keeps getting entries):

    Dec 17 16:05:38 leosol sendmail[1824]: hBHL2ThB001824: to=scowby@yahoo.com, ctladdr=apache (48/48), delay=00:03:09, xdelay=00:03:09, mailer=relay, pri=30064, relay=mybox.mydomain.com. [216.34.94.184], dsn=4.0.0, stat=Deferred: Connection timed out with mybox.mydomain.com.



    I should have mentioned that my machine uses DHCP to get it's IP and doesn't really have a domain name. Is there a configuration issue w/ sendmail and domain names. I guess I'm not really sure why sendmail is trying to contact mybox.mydomain.com instead of being able to send out to yahoo.com directly.

    As far as qmail goes - will that solve my problem with PHP (isn't PHP looking to use the binary in /usr/sbin/sendmail?)

    Thanks for the help!
  6. #4
  7. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Dec 2003
    Posts
    9
    Rep Power
    0
    Ok, I *think* I figured out the problem.

    It looks like sendmail was trying to figure out who mybox.mydomain.com was. I had this in my /etc/hosts file:

    127.0.0.1 mybox.mydomain.com localhost.localdomain localhost mybox


    I think sendmail resolved 127.0.0.1 to mybox.mydomain.com and tried to do a DNS lookup on it and couldn't resolve it, and thus was timing out. That's my best guess.


    I changed /etc/hosts to look like:

    127.0.0.1 localhost.localdomain localhost mybox

    And it sent the mail out. Yeah!

    If anyone can help me figure out REALLY what was going on that would be appreciated.

    But thanks for the help!
  8. #5
  9. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    May 2009
    Posts
    1
    Rep Power
    0

    php mail not delivered


    Hi guys. I know its been way back you put this up but i have a similar challenge. i use php5, mysql5, iis6 on windows 2003 server. my application doesnt deliver mails. it used to deliver previously but suddenly stopped working. i use the mail exchange server on our intranet which sends and delivers outlook mails without issues. smtp in my php.ini file is the ip address of teh mail server. my code is as thus:

    <?php
    $to = "spotlite'at'mysitecom";
    $subject = "Hi!SPOTLITE mail";
    $body = "Hi,\n\n A report has just been submitted.Please view the decision board. ";
    $headers = "From:"tlite'at'mysitecom" ."\r\n" .
    "CC:slite'at'mysite.com,plite'at'mysite.com,hlite'at'mysite.com";
    $sent = mail ($to,$subject,$body,$headers);
    if ($sent){
    echo "We will get back to you in 72 hours.\nThank you!";
    }
    else
    {
    echo 'Please note that HR could not be informed of your input. Contact System Administrator';
    }
    ?>

    does anyone have any clue to what i can do about it? Thanks.

IMN logo majestic logo threadwatch logo seochat tools logo