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?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

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:


Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
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.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.