Wednesday, May 06, 2015

MAMP PRO and Postfix

MAMP PRO only uses Postfix from Mac OS X to implement basic mail-sending capabilities. It was designed to help developers to check if their mail scripts are working correctly, to see if all the information that is supposed to be in a mail, is really there, to check the layout and so on. It was never intended to use Postfix as a full-fledged email server replacement. Please keep that in mind.

A minimal Postfix setup is simple. We use Googles Gmail service as an example to demonstrate the workings of Postfix.

In the Postfix section of MAMP PRO please set the domain of outgoing emails to "gmail.com". Leave the Smart Host checkbox unchecked.

Click the Button "Use this data". In Postfix' log file you will see something like

Dec 12 09:10:48 Tonne postfix/master[31865]: daemon started -- version 2.9.4, configuration /etc/postfix

The log file is located at /var/log/mail.log and can be viewed with Console.app.

In MAMP PRO, create a host (let's call it postman) and assign it a document root folder.

In a text editor create a PHP script, a basic mail-sending PHP script would look like

Please replace to.address@gmail.com and from.address@gmail.com with working Gmail addresses. Save the script to the document root folder of postman.

Make sure the servers of MAMP PRO are running and click on the right arrow located next to the field "Server name" in the General section of the Hosts view. Your web browser should open and show the message "Testing Postfix...".

In /var/log/mail.log new entries will appear, similar to

Dec 12 09:11:26 Tonne postfix/pickup[31994]: EF76490ECED: uid=502 from= 
Dec 12 09:11:26 Tonne postfix/cleanup[31995]: EF76490ECED: message-id=<20141212081126 .ef76490eced="" mailer.gmail.com=""> 
Dec 12 09:11:27 Tonne postfix/qmgr[31997]: EF76490ECED: from=, size=391, nrcpt=1 (queue active) 
Dec 12 09:11:28 Tonne postfix/smtp[31998]: EF76490ECED: to=, relay=gmail-smtp-in.l.google.com[74.125.136.27]:25, delay=2.2, delays=1.1/0.02/0.38/0.69, dsn=2.0.0, status=sent (250 2.0.0 OK 1418371832 k5si1095875wjf.30 - gsmtp) 
Dec 12 09:11:28 Tonne postfix/qmgr[31997]: EF76490ECED: removed

The most important information is status=sent. This means Postfix has handed the message over to Gmail which has accepted it. The last line indicates that Postfix has removed the message from its local queue, Postfix has done its work!

If, and where to, Gmail delivers the message is out of the hands of Postfix now. Please check your spam folder if the message does not show up in your inbox. Make sure you are looking in the correct spam folder, on Gmails webpage it's hidden behind "More" in the folder hierarchy on the left side.

If you need more sophisticated email capabilities you might want to use a Smart Host. In this case, please contact your email provider for the correct settings. Typically, free accounts do not have smart host capabilities.

Share/Save/Bookmark