How to find error log for php mail errors

I have a PHP page which sends emails that contains information about course registrations. The only problem is that for a limited amount of time, I commented out the sender address by a mistake, so that no mails were sent.

Is there any way to  find an error log which shows me the mails that weren't sent?

The webpage itself did not return an error.
Who is Participating?
CIGHNConnect With a Mentor Commented:
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.


<title>PHP mail() test</title>


$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 you can visit these sites:

beesterAuthor Commented:
The php mail script works, but I can't seem to find the mailerror.log file anywhere. I tried making a tmp directory under the php home folder without any luck. Where's the tmp folder to be located?
beesterAuthor Commented:
Nevermind, I put in /php/tmp after i made the tmp subfolder to the php directory, and it creates the mailerror.log

Thanks alot!
Check out this site I beleive your answer is here.
All Courses

From novice to tech pro — start learning today.