I found this awesome tutorial on how to send emails on localhost that will open your Mail showing you the email that was sent from PHP, however this is slightly annoying getting Mail to open when an email is sent - I have some tasks that run in the background which sends an email for development reasons for my site so I can test the emails.

I want to be able to not get annoyed by getting popped up with emails, instead I would like it to pipe it to Mail and show in my inbox when I click "Get new messages" so I can look into the email whenever I want not at the instant when the email is sent.

I've looked into where Mail stores their email ~/Library/Mail/V2, I was wondering if I could adjust the script to add the email there, but it looks quite complication so I don't want to risk having any confusion or corruption happening.

Is there any possibility to store the mails without any problems so Mail can add it to my inbox list via PHP?


  • Why do you not set up a seperate email account for your testing that does not check for messages automatically? Tampering with the mailbox files is not recommended and likely to break.
    – Gerry
    Aug 16, 2012 at 14:31
  • I don't understand? In the PHP script, it runs a command of opening the email with Mail, not Mail fetching the email. Please read carefully.
    – MacMac
    Aug 16, 2012 at 14:51
  • All the script does it writing a .elmx file which is then opened by Mail. This already is (honestly) quite a hack and you will run into even more trouble if you start to mess around with ~/Library/Mail. The better road to take is definitively to enable the local sendmail and just send a mail locally.
    – nohillside
    Sep 4, 2012 at 14:14

1 Answer 1


You can do what you ask, but it requires a Mailbox > Rebuild operation. That asks Mail to scan the ~/Library/Mail directory you found and rebuild its email header database from the files it finds there. I doubt you'd find that acceptable.

I'm afraid Gerry's comment above is the right way to go about this: set up a test email account somewhere, use one of the many PHP-to-SMTP methods you can find online, and point Apple Mail at that email account.

Perhaps the simplest, most Apple-like way to achieve that end is with OS X Server. It gives you a configuration UI for the Postfix SMTP mail server built into OS X. Setup through the Server GUI is about as easy as you can hope for. You can create a private user account, and be assured that your test emails won't ever even leave the machine. As cheap as OS X Server is these days, it's pretty much a no-brainer.

If you absolutely have to do this for no cost, you can configure Postfix by hand. The configuration GUI you get with OS X Server is helpful, but not strictly necessary.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .