php mail() function painfully slow on local development machine

Well I know that this is not what you are asking, but why you don't try Postfix or Exim? They're both available to ubuntu (Postfix is even the default mta on Ubuntu systems) and they both provide a compatible 'sendmail' command that works very well. IMHO sendmail is kind of dated and you will get better chances of support with more modern MTA.


This worked for me:

  • Install postfix

See instructions here on how to do this here: https://help.ubuntu.com/community/Postfix (It may already be installed, and the 'sendmail' binary may actually be an alias for postfix)

  • Follow instructions here:

http://lenss.nl/2009/01/making-php-mail-work-on-ubuntu-through-postfix/

mkfifo /var/spool/postfix/public/pickup

Find the sendmail process

ps aux | grep mail

Kill it

kill <thepid>

Restart postfix

/etc/init.d/postfix restart

I think you can just set the 'myorigin' parameter to any active domain name such as a domain name you own.


This may or may not be a solution for you: add mail.force_extra_parameters = "[email protected]" to your php.ini file. It makes PHP automatically append [email protected] as a fifth parameter to PHP's mail() function.

That's a hardcoded value and only applicable in php.ini so it won't be very flexible, but perhaps works for you in your development case?