How can I use PHP Mail() function within PHP-FPM? On Nginx? How can I use PHP Mail() function within PHP-FPM? On Nginx? nginx nginx

How can I use PHP Mail() function within PHP-FPM? On Nginx?


If found that on a new installation of Ubuntu 14.04 with nginx and PHP-FPM (no apache), neither postfix nor mailutils were installed.

I used:sudo apt-get install postfix

(as in the recommended answer)

AND

sudo apt-get install mailutils

to get everything working on my server. Both were required. An entry in PHP.ini (as mentioned in the recommended answer) may also have helped, but without both of the other packages, it wouldn't have made a difference.


As there is no value for sendmail_from you need to set one in php.ini:

sendmail_from = "you@example.com" 

Or in the headers when you call to mail:

mail($to, $subject, $message, 'From: you@example.com');

The email address should follow RFC 2822 for example:

  • you@example.com
  • You <you@example.com>

Failing that, have you actually installed a working email system?

If not, you can install postfix with the following command:

sudo apt-get install postfix

See below for more information on configuring postfix for use with PHP in Ubuntu:

https://serverfault.com/questions/119105/setup-ubuntu-server-to-send-mail