Get log of mail sent with mail() from PHP (sendmail?)
Solution 1
On Debian-based systems exim logs data in /var/log/exim4/mainlog
.
You might find the eximstats tool useful for parsing and culling useful information out of that log file.
Solution 2
sendmail -bp
(and mailq
) only lists the mail queue: messages queued but not yet sent. It will not include those messages which were delivered successfully.
You should check /var/log/mail.log
(and other logfiles) - they almost always have records of every transfer.
Solution 3
php 5.3.0 added 2 settings that makes tracking down rogue scripts easy:
mail.add_x_header
mail.log
http://php.net/manual/en/mail.configuration.php
Related videos on Youtube
Comments
-
Kristopher Ives over 1 year
After some server changes our PHP configuration got nuked, which caused a client's large mailing list to time out partially through about 4,000 addresses or more. We want to avoid sending a duplicate mail as much as possible, and we have the original mailing list.
The mail was sent using PHP's
mail()
function, which usessendmail
, which says it's usingExim
. I've seen the command:sendmail -bp
Which gives me a list of mail that appears was sent. This list isn't very big, and could be accurate (meaning the script timed out after sending only a hundred or so e-mails)
Is
sendmail -bp
the best way to get this listing?EDIT: I can't find any
mail.log
file in/var/log/mail.log
or vialocate mail.log
, but WHM seems to have some information on this.-
Antoine Benkemoun almost 14 yearsWhat about /var/log/maillog ?
-
-
yitwail about 11 yearsIn centos, and probably RHEL/fedora, it's in /var/log/exim_mainlog