Trinidad Weather

Subscribe Here

Enter your email address:

Delivered by FeedBurner

Plentipeppa News

Postfix on macOS El Capitan

Postfix set up on macOS El Capitan

Facebooktwittergoogle_plusmail

I decided to write this little tutorial to help those who want to set up and run Postfix as a mail relay on their Mac Computer for website and web server development purposes.

Lots of hobbyist and people interested in do it yourself and self hosted websites often have problems setting up a postfix as their mail relay program on their developmental web server.

With the availabilty of Content Management Software such as WordPress, available here.
Anyone can host their own website on their own home computer. All you need is an internet connection.

During testing of your website, you may and will need to send email directly from your site or web server.
Most online help or tutorial always refers you to playing around with the Terminal command line.
Sometimes this can be very daunting to novices like me who don’t understand all the command line Terminology, such as sudo, vim, nano and other terminology that some say is necessary in order to set up Postfix.

Some will swear, that using the terminal command line is the easier and right thing to do, but I have done it another way and it has been working for me.

I know there are some who might suggest that this is a clumsy way, but this is for those who want it without all the command stuff.

So lets move right along, but before you start, you must have a text editor at hand. You can use any text editor you want, but I prefer to use BBedit downloaded from Barebones site. BBedit that is downloaded from the Apps Store is too restrictive.
For those of us who are using MAMP or MAMP PRO, there will be no need to set up postfix or use Smarthost that comes built in to MAMP PRO.

So moving along, here are the steps to be followed that will get your Postfix Mail relay up and running.

Make sure you have the minimum Postfix Configuration, they may be grouped together or found separately in the  Main.cf file.
These settings will work on el Capitan and macOS Sierra, whenever you upgrade.

1|mail_owner = _postfix
2|setgid_group = _postdrop

This line may also be found separately also in the Main.cf file
3|tls_random_source=dev:/dev/urandom

Step 1.

Click on Finder then click on go to folder

type  /etc/postfix in the dialog box then hit enter

find the Main.cf file and add these few lines at the very bottom

#Gmail SMTP
relayhost=[smtp.gmail.com]:587
#Enable SASL authentication in the Postfix SMTP client.
smtp_sasl_auth_enable=yes
smtp_sasl_password_maps=hash:/etc/postfix/smtp_sasl_passwd
#smtp_tls_sites_maps=hash:/etc/postfix/smtp_tls_sites
smtp_sasl_security_options=noanonymous
smtp_sasl_mechanism_filter=plain
#Enable Transport Layer Security (TLS), i.e. SSL.
smtp_use_tls=yes
smtp_tls_security_level=encrypt

Save and exit

For relayhost you can choose whatever you want your relay host to be but it must be in the format above.

Step 2.

Create two files using your text editor of choice…………

(a). Place this line in your file
[smtp.gmail.com]:587 user_name@gmail.com:your_password
This should be your User Name and Login credentials for whatever email service you want to use as your relay host.

Save this file as smtp_sasl_passwd then exit.

(b). Place this line in the other file
[smtp.gmail.com]:587 MUST_NOPEERMATCH

Save and exit this file as smtp_tls_sites

Step 3.

Go to you Terminal program, it can be found from your Launch pad, open up terminal and type

sudo postmap /etc/postfix/smtp_sasl_passwd

hit enter, it will then ask you for your password, type in your password, then hit enter

This will create a smtp_sasl_passwd.db file in you postfix folder.

Next, in the Terminal program type     sudo postmap /etc/postfix/smtp_tls_sites

hit enter , it will then ask you for your password, (this will be your computer user name password) type in your password then hit enter.

This will create a smtp_tls_sites.db file in the postfix folder.

Step 4

Go to you Terminal program and type  sudo postfix reload

it may ask for password, (this will be your computer user name password) type in your password then hit enter.

Next type sudo postfix  start then hit enter.

If you encounter any problems or errors, go to Finder and then the go to Folder, in the dialog box type

/etc/hosts  then hit enter or Go.

Look for the folder named postfix, click or highlight that folder, then go to Action at the top of the page and click on the down arrow then click on Get info.

On the pop up box , click on the padlock on the bottom right side, a  dialog box will appear, type your user name and password.

Etchost

Add you  user name  and give Read, Write permission if it not there, then click on the little sprocket to apply to all files and repeat Step 3 and 4 above.

After this, everything should work……….

This is the set up I have and everything works perfectly.

The above settings will also work on macOS Sierra, if and when you upgrade from El Capitan, it’s been working very well for me.

Your feedback will highly be appreciated

Update as of October 1st 2016, I now have a full email server running on my Mac on a dedicated static ip. I can send and receive mail for my domains as well as any other domain I have hosted on my server.
Server runs on macOS Sierra with Server App 5.2

I already have a couple hosted domains I receive and deliver mail to.
If anyone is interested, I can host your domain email on my mail server for free.
What you will get is a personalized email of your choice to matched your domain, e.g Joe@yourdomain.

Just send me an email if you are interested.

15 comments to Postfix on macOS El Capitan

  • Andy Moyle

    Hi there,
    I’ve created the two files and saved them in the postfix folder using Text Wrangler.
    When I do sudo postmap /etc/postfix/smtp_sasl_passwd
    I get this error…

    postmap: fatal: open database /etc/postfix/smtp_sasl_passwd.db: Permission denied

    What do I need to do?

  • Plentipeppa Plentipeppa

    Reread Step 4, you have to give read write permission to the smtp_sasl_passwd file.
    If you are using google gmail credentials, you have to log in to you google account and turn on less secure app…..
    Also in your config file in main.cf
    make sure you have this line 1|smtp_sasl_mechanism_filter=plain

  • Sasi

    I followed your instructions and this is what I get. I made gmail to allow less secure applications.

    Sep 20 14:14:54 Szabolcss-MacBook-Air postfix/pickup[48259]: B2771AA552B: uid=501 from=
    Sep 20 14:14:54 Szabolcss-MacBook-Air postfix/cleanup[48376]: B2771AA552B: message-id=
    Sep 20 14:14:54 Szabolcss-MacBook-Air postfix/qmgr[48260]: B2771AA552B: from=, size=396, nrcpt=1 (queue active)
    Sep 20 14:14:55 Szabolcss-MacBook-Air postfix/smtp[48378]: B2771AA552B: to=, relay=smtp.gmail.com[74.125.206.109]:587, delay=0.74, delays=0.07/0.07/0.56/0.04, dsn=5.5.1, status=bounced (host smtp.gmail.com[74.125.206.109] said: 530-5.5.1 Authentication Required. Learn more at 530 5.5.1 https://support.google.com/mail/?p=WantAuthError r2sm20481422wmf.14 – gsmtp (in reply to MAIL FROM command))
    Sep 20 14:14:55 Szabolcss-MacBook-Air postfix/cleanup[48376]: 7863FAA552D: message-id=
    Sep 20 14:14:55 Szabolcss-MacBook-Air postfix/qmgr[48260]: 7863FAA552D: from=, size=2654, nrcpt=1 (queue active)
    Sep 20 14:14:55 Szabolcss-MacBook-Air postfix/bounce[48379]: B2771AA552B: sender non-delivery notification: 7863FAA552D
    Sep 20 14:14:55 Szabolcss-MacBook-Air postfix/qmgr[48260]: B2771AA552B: removed

    • Plentipeppa Plentipeppa

      Hi there!
      Did you follow the instructions properly?
      Did you eventually get it to work?
      Before posting sensitive information on line, redact your ip numbers or change them for security reasons.

  • Sasi

    … sry, was a bit pissed. Trying everything and nothing works. Eventually there seems to be a problem with the authentication.

    I must add that I am using MAMP4.X.X PRO. Before with MAMP PRO 3 this was just a no issue to send out emails from localhost. (I don’t even remember having setup anything…)

    • Have been using postfix and MamPro and Xampp since OS X Lion and had very little problem.
      Now I totally use MamPro and just recently upgraded to MAMPPRO 4X.X with no problems whatsoever.

      Did you try using………
      smtp_sasl_mechanism_filter=plain

  • KevDog

    Is this correct: [smtp_gmail.com]:587 MUST_NOPEERMATCH
    or should it be
    [smtp.gmail.com]:587 MUST_NOPEERMATCH

    • Plentipeppa Plentipeppa

      Wow! thank for the correction KevDog.
      This probably happened when I edited something recently.
      This is correct [smtp.gmail.com]:587 MUST_NOPEERMATCH
      Everything else remains the same

  • jahrvos

    hi, thanks a lot for the instructions.
    i ran into a strange error under macos sierra. After following your instructions I get this:
    $ postfix status
    postfix/postfix-script: the Postfix mail system is running: PID: 33741
    $ mailq
    postqueue: fatal: Queue report unavailable – mail system is down

    Do you have any clue?

  • Nitin

    Hi all,

    I am using macOS 10.12.2. I had done all changes what ever mentioned above but when I tried to send mail i have not got any output. command is stuck. Also not found any mail log in log directory under /var/log. Pls help me for it.

  • zaza41rus

    Not found any mail log in log directory under /var/log.

  • zaza41rus

    macOS 10.12.3
    i have same problem, no /var/log/mail.log, also no config_directory = /etc/postfix, tried to add it manually, in terminal entered
    –>
    date | mail -s testing zaza41rus@gmail.com
    –>
    , but nothing changed

Leave a Reply