In order to test mail sending while developing websites in PHP, I want to just save all sent mail locally in mbox format. In order to do that, I was going to set sendmail_path in php.ini to something sendmail-compatible that can just put the email in a spool file.

One solution I know of is to set up a full-blown MTA like postfix to deliver the mail locally. However, I don't want to run a daemon for this.

Is there a simple solution? What can I use? Or maybe I'm trying to do something wrong?

1 Answer 1


That will be nullmailer

Official page: http://untroubled.org/nullmailer/ Official git: https://github.com/bruceg/nullmailer

And here is some guides: General nullmailer setup, Nullmailer + FakeSMTP server

It still runs as service though, since it has queuing in there.

If you want a completely serviceless MTA, please have a look at http://msmtp.sourceforge.net - it doesn't require to run an MTA service, instead it works as a relay, by sending your mail via an external server. You can combine it with FakeSMTP script to get what you need. Beware, that relaying mail via an external server has a huge downside - your PHP script/web-server won't respond until the mail is actually send. Most public mail servers implement a delay for authorization, which can be as long as 30-40 seconds. So you'd have that delay for each & every letter you send (for a user it will look like script is not responding).

All those apps above are really sending mails, and can be used in production environment. If you want a developer version which does almost nothing - please have a look at this shell script: https://github.com/Sanchiz/fake_sendmail.sh, you can easily modify those 20 lines to your needs (first of all remove that line that sets 777 on resulting file, you don't want that), though I'd recommend to go with something less simple...

  • Why would there be 30 seconds delays? It would be sending mail from localhost to localhost.
    – jojman
    Sep 5, 2016 at 2:36
  • Added some explanation...
    – Anubioz
    Sep 5, 2016 at 2:51

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.