I'm developing a web application in PHP, and my Macbook, running Snow Leopard, is actually sending emails when PHP's mail() function is called. It's emailing customers, and that's BAD.

I COULD prevent this in my code, but I'd rather just disable mailing for my machine. Is there a way to do this under Mac OS?

  • 2
    If you're doing development on your macbook, you should really not have customer information in the db. Only test data should be in there. Imagine how much could be compromised if you lost your laptop, or worse, it was stolen.
    – davethegr8
    Dec 15, 2009 at 22:47

4 Answers 4


The simplest answer is to have a switch in your send logic that checks whether or not DEVELOPMENT is defined. If it is, it outputs the mail to a file, other wise, it assumes a production environment and continues with the normal send process.

All you need to do is set DEVELOPMENT = TRUE in your config and you can play around without disturbing customers!

Your local postfix config is located in /etc/postfix. There seems to be a duplicate at /private/etc/postfix but i'm not so familiar with OSX. On linux i could just remove the daemon and stop the service from running. This might cause runtime errors for your programs and seems unecessary.

  • 1
    This is exactly what I ended up doing: 1) used an IS_DEVELOPER flag and 2) disabled postfix. Actually for (2), I moved /usr/sbin/sendmail to /usr/sbin/sendmail.original and put a dummy sh script in place of sendmail, as I read that sendmail uses Postfix when Postfix is running but can still send out emails otherwise. I don't need outgoing email functionality on this machine, so this solution works for me. Dec 16, 2009 at 1:13
  • 2
    /etc/ is a symlink to /private/etc/ so they're the same file. (The same occurs with /var and /tmp as well on OS X).
    – Chealion
    Dec 16, 2009 at 4:34

To partially disable postfix run sudo launchctl unload /System/Library/LaunchDaemons/org.postfix.master.plist

However the mail you're attempting to send will get stuck in /var/spool/postfix/maildrop but will not send.


Easiest thing I can think of (If you only use web mail or Imap), simply at the network (router) level block outgoing of port 25 from your machine, or use the OS X firewall and block port 25 outgoing.

IF this doesn't work, I would simply look at putting a non existent relay in to your php.ini so all mail simply fails to send....

However, you would be better off using a real relay that simply does not send out but looks like it does - blocking at the firewall or application or fake relay could all produce errors that you may not account for and cause problems when you do actually go live.


You need to compartmentalize your development environment from your release environment.

That is the solution to your real problem.

You must log in to answer this question.

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