Search Help

How can I retrieve PHP mail errors?

You'll find your error logs for PHP and Perl mail in the tmp subdirectory in your File Manager, in a log file called mailError.log. Messages are saved to this file automatically whenever an error occurs.

If the tmp directory is not present or has been deleted, error logs cannot be saved. We also suggest you password-protect the tmp directory, as it may contain sensitive data.

The sample PHP mail script below will help you test your mail error log. This script will notify you if the mail function failed, as well as check the size of the error log. Be sure to change the EMAIL TO value to that of a valid email account. 

PHP mail() test

$email = "EMAIL TO";
$subject = "Test Message";
$msg = "This is a test message";


//Get the size of the error log
//ensure it exists, create it if it doesn't
$fh= fopen($eLog, "a+");
$originalsize = filesize($eLog);


* NOTE: PHP caches file status so we need to clear
* that cache so we can get the current file size

$finalsize = filesize($eLog);

//Check if the error log was just updated
if ($originalsize != $finalsize) {
print "Problem sending mail. (size was $originalsize, now $finalsize) See $eLog
} else {
print "Mail sent to $email";

To learn more about PHP, we suggest consulting the PHP Group web site or other PHP resources.

Thank you! Your feedback has successfully been submitted.

Please tell us why you didn't find this helpful.

Send Feedback