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