1 Star2 Stars3 Stars4 Stars5 Stars (No Ratings Yet)
Loading ... Loading ...

Where to check if PHP mail() function is not working


Lots of time we find php mail() function is not working. In some cases, the email is not sent even the function returns true. Following are the points you may check while debugging:

  1. First check if the sendmail_path variable is set properly. You can see it from echo – ing phpinfo() in a page. The typical value is /usr/sbin/sendmail -t -i
  2. If you are sending extra headers in the 4th parameter of the function, try to remove it and send. It is a very common scenario to have incorrect header in the mail function.
  3. Check if you have a spam filter installed in your server which is blocking your email.
  4. If you have access check your mail log file to see if the email is blocked by the mail server or have not reached the server yet. If there is no entry of your email in the log, it means you have problem in your php code or php configuration. If it is in the log, you can see why it was not delivered.
    The typical path to mail log file is /var/log/maillog

If still you can’t find any problem, contact your host.
For sending email, I always prefer the old and great phpmailer class. The ultimate answer to all your php emailing issues. You can also try pear Mail package.

Bookmark and Share

,

  1. #1 by Asif on July 27th, 2009

    Helped me, thanks

  2. #2 by Imran on July 27th, 2009

    Good to know that, keep coming.

(will not be published)
Security Code:

  1. No trackbacks yet.