Log from Sendmail and PHP

If I leave my default sendmail options set in php.ini it works fine and sends an email. However if I change the sendmail path to:

sendmail_path = "sendmail -t -i -x /var/log/mail.log"

mail() returns false.

If I run:

ls -l /var/mail/mail.log

I get:

-rwxrw-rw- 1 www-data www-data 0 Sep 17 14:49 /var/mail/mail.log

Which I believe is correct. All I want sendmail to do is log my emails but for some reason it really really doesn't want to play ball!

Just for clarity - this isn't the mail.log parameter which logs the PHP interactions with the script. The output when this is set is something like this:

[17-Sep-2016 15:38:20 Europe/London] mail() on [/home/server/www/dev1/htdocs/mail.php:15]: To: TO -- Headers: MIME-Version: 1.0 From: ME

2 Answers

The problem in this instance was that I was using -x and not -X. Once I did the capital it worked fine!

1

If you use PHP version 5.3.0 or newer then correct answer will be to use mail.log directive in configuration like said in manual.

2

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

You Might Also Like