Setting up mail on MAMP on El Capitan
I’ve only recently switched over to Macs and have found setting up mail sending on the MAc’s MAMP as hard as Windows! So here’s how.
Firstly it all needs to be down in the “Terminal” – so click on Finder, then Applications, then Utilities to open a terminal (looks pretty similar to Windows CMD!)
Check a program called Postfix exists by typing
That should give you the following errors – which for once is good news!
postfix: error: to submit mail, use the Postfix sendmail command
postfix: fatal: the postfix command is reserved for the superuser
Next we can start configuring for gmail – but first head over to you gmail account to set up using for less secure apps
In the terminal type or copy and paste
sudo vi /etc/postfix/main.cf
Than type your password and enter.
Scroll down and check the following lines exist…
mail_owner = _postfix
setgid_group = _postdrop
Editing took some googling for me as it is not intuitive! Here’s a cheatsheet
i) To delete – put the cursor over the character and press x
ii) To start inserting – place your cursor and press i, then start type or use copy (CTRL C) and paste (CTRL V).
To exit with out saving press
To exit with saving press
At the bottom of the file add the following
# Use Gmail SMTP
relayhost = smtp.gmail.com:587
smtp_sasl_mechanism_filter = plain
smtp_sasl_auth_enable = yes
smtp_sasl_password_maps = hash:/etc/postfix/sasl_passwd
smtp_use_tls = yes
smtp_tls_security_level = encrypt
tls_random_source = dev:/dev/urandom
You can change the relayhost to whatever server you like, I’m using gmail.
We need to create a gmail username/password file. So save and exit the main.cf file –
sudo vim /etc/postfix/smtp_sasl_passwd
and press i to start inserting again and add the following line
Save the file using
Now we need to get it turned into what postfix wants by typing
sudo postmap /etc/postfix/smtp_sasl_passwd
Next we need to set it up for TLS
Press i to start editing and add
And then type
sudo postmap /etc/postfix/smtp_tls_sites
sudo postfix start
Now we just need to test it all!
echo "Test sending email from Postfix" | mail -s "Test Postfix" firstname.lastname@example.org
A quick php script to test from your MAMP server
Lastly to make these changes work for starting up your mac we need to do some more worrk, changing a file called /System/Library/LaunchDaemons/org.postfix.master.plist
which is read only because it is being used!
sudo launchctl unload /System/Library/LaunchDaemons/org.postfix.master.plist stops it!
Add the following before
And then restart the daemon thingie…
sudo launchctl load /System/Library/LaunchDaemons/org.postfix.master.plist
Hope that helps you!