2

A web server I manage is having problems sending mail from PHP. This server uses exim4 for MTA, and it is configured correctly.

I can send emails from PHP's CLI, but not from the web. i.e. if I do "php mailtest.php" on the command line, the email gets sent correctly, but if I browse to server.com/mailtest.php, mail() returns false and the email never gets sent. Nothing appears in the exim mainlog.

Any advice, or things I should look for ?

Thanks!

  • What distro? Are you running in an SELinux-protected configuration? – jgoldschrafe Nov 8 '10 at 12:01
  • @jgoldschrafe Debian 5.0.6 and no. – jfoucher Nov 25 '10 at 19:09
  • I'm facing the same issue. It seems like permission issue. Have you fix this issue? – Yasiru G Mar 29 '18 at 10:14
2

It sounds like you've got different versions of php.ini located under /etc/php5/

debian:/etc/php5# find . | grep php.ini
./cli/php.ini
./apache2/php.ini

Check the [mail function] directive

| improve this answer | |
  • I did, they're the same in both files. I actually copied one to the other (and the other way around) and got the exact same results – jfoucher Nov 25 '10 at 19:11
  • 1
    Do a phpinfo() and add the php server information "sendmail" to your question. Exim will normally replace the sendmail binary with the send compartible exim binary. – DrDol Dec 28 '10 at 22:39
0

You should change your PHP configuration to send emails through exim.

If you use Apache2 as a webserver:

; /etc/php5/apache2/conf.d/mail.ini 
[mail function]
sendmail_path = /usr/sbin/exim4 -t
mail.add_x_header = On
mail.log = syslog

If you use nginx+FPM:

; /etc/php5/fpm/conf.d/mail.ini
[mail function]
sendmail_path = /usr/sbin/exim4 -t
mail.add_x_header = On
mail.log = syslog

Then restart your services:

sudo service apache2 restart

or:

sudo service php5-fpm restart
| improve this answer | |

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.