Linux / UNIX: PHP mail() Error Log File

by on November 12, 2010 · 1 comment· LAST UPDATED November 12, 2010

in , ,

How do I view PHP mail() errors? How do I see php mail() error log file under UNIX or Linux?

Usually, mail log including errors are sent to your systems mail server log directory. If you are using CentOS / RHEL / Redhat or Fedora Linux, check /var/log/maillog file using any one of the following command:
# tail -f /var/log/maillog
# grep '' /var/log/maillog
# more /var/log/maillog

If you are using Ubuntu or Debian Linux, check /var/log/mail.err and /var/log/mail.log files:
# tail -f /var/log/mail.log
# tail -f /var/log/mail.err

Sample PHP Code To Test Your Log File

Create a php code or upload a file called mailtest.php as follows:

<title>nixCraft PHP: Test mail() </title>
$email = "";
$subject = "Happy Birthday!";
$msg = "Wishing you all the great things in life, hope this day will bring you an extra share of all that makes you happiest.";

Run this as:
And check your server log files as mentioned above.

Tweet itFacebook itG+ itDownload PDF versionFound an error/typo on this page?

{ 1 comment… read it below or add one }

1 Adam Ziaja August 14, 2011 at 6:46 pm

or just php script.php


Leave a Comment

Tagged as: , , , , , , , , , , , , , , ,

Previous Faq:

Next Faq: