You'll find your error logs for PHP and Perl mail in your tmp subdirectory, in a log file called mailError.log. Messages will be saved to this file automatically whenever an error occurs.
If the tmp directory is not present or has been deleted, our system will discard the error logs. We also strongly 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 for changes. Be sure to change EMAIL TO value to that of a valid email account.
<html>
<head>
<title>PHP mail() test</title>
</head>
<body>
<?php
$email = "EMAIL TO";
$subject = "Test Message";
$msg = "This is a test message";
$eLog="/tmp/mailError.log";
//Get the size of the error log
//ensure it exists, create it if it doesn't
$fh= fopen($eLog, "a+");
fclose($fh);
$originalsize = filesize($eLog);
mail($email,$subject,$msg);
/*
* NOTE: PHP caches file status so we need to clear
* that cache so we can get the current file size
*/
clearstatcache();
$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.