NYCPHP Meetup

NYPHP.org

[nycphp-talk] need help with debugging mail()

Hans Zaunere hans at nyphp.org
Thu Nov 20 19:08:40 EST 2003



Michael Southwell wrote:
> I am moving a site from one server to another one (the new one is in nyc 
> and has a 2-letter extension ;-).  The contact form on the old site is 
> working perfectly, but identical code on the new one isn't.  Phpinfo 
> tells me that sendmail is there and presumably working.  Docs say that 
> mail() returns TRUE or FALSE so I tried this code:
> ----------------
> if (mail($to,$subject,$message,$from)==FALSE) do something
> else do something else
> --------------
> which always does something else so mail seems to be returning TRUE but 
> the message never arrives.  How do I do a better job of debugging what's 
> happening?

Do you have shell access?  If so, ssh in and do something like:

mail your at email.com

fill in the subject and enter a period on it's own line to finish up the body of the message.  If you get the email, then the mail subsystem is probably fairly sane.  If not, it's not sane, and you need to tinker with sysadmin stuff to get it working.

You can also view the system mail logs.  Depending on the platform, it's probably /var/log/maillog

Depending on the success of the step above, do:

tail -f /var/log/maillog

while trying the webpage or using the mail command from a terminal.  If the mail command works, but the webpage doesn't, ensure that your permissions are set correctly.  The settings php.ini has for mail (noteably the sendmail command) needs to be readable and executeable by the user apache is running as, or as the user if it's cgi.

H



More information about the talk mailing list