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.
LVL 7
beesterAsked:
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.


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

http://www.php.net/

http://books.search.shopping.yahoo.com/search/books?p=PHP&f=all

http://dir.yahoo.com/Computers_and_Internet/Software/Internet/World_Wide_Web/Servers/Server_Side_Scripting/PHP/



0
 
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?
0
 
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!
0
 
CIGHNCommented:
Check out this site I beleive your answer is here.
http://www.bigresource.com/PHP-clear-cache-temp-data-buffer-IHHtXiNu.html
0
All Courses

From novice to tech pro — start learning today.