Ah ok, here’s a comprehensive tutorial on how to setup postfix email server on a Mac running Sierra to Mojave if you ever find yourself in a similar situation of having to remotely fix a Mac web server running these version >.< Be prepared to use terminal and a lot of nano or vim editor.

Step 1.) Create a sasl_passwd file

 $> sudo vi /etc/postfix/sasl_passwd
Add the your preferred smtp server and credentials to the file
smtp.gmail.com:587 [email protected]:PASSWORD
the last step is to Create a lookup table
$> sudo postmap /etc/postfix/sasl_passwd

Step 2.) Edit the main.cf file

$> sudo vi /etc/postfix/main.cf
Edit these values if they are not set already
mail_owner = _postfix
setgid_group = _postdrop
Add these fields at the end of the file, you can use any other relay hosts. For continuity I'd be sticking with gmail.
# Enable SASL authentication in the Postfix SMTP client.
# Enable Transport Layer Security (TLS), i.e. SSL.

Step 3.) Disable SIP(System Integrity Protection)

Reboot your mac in to recovery mode. You can reboot into recovery mode by Holding down command+r while booting. Otherwise if you’re on a windows keyboard or you prefer a command line approach Simply enter the following commands in the terminal:
$>sudo nvram "recovery-boot-mode=unused"
 $>sudo reboot
This sets a firmware variable in nvram indicating that you want to start in Recovery mode on the next boot, and then reboots the machine. When done in Recovery mode, run the following from the Terminal in Recovery mode:
$> nvram -d recovery-boot-mode
Once in recovery mode:
  • Click Utilities.
  • Select Terminal.
  • Enter csrutil disable.
Note: To enable SIP simply enter csrutil enable instead.

Step 4.) Set postfix to autorun on reboot

Now reboot out of recovery mode. Open a terminal and edit the following file.
 $>sudo vi /System/Library/LaunchDaemons/com.apple.postfix.master.plist
Remove these lines
and add these lines at the start of the plist definition
The modified file should look something like this:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" 
<plist version="1.0">

Now Reload and relaunch the deamon with the following commands:
$> sudo launchctl unload /System/Library/LaunchDaemons/com.apple.postfix.master.plist
$> sudo launchctl load /System/Library/LaunchDaemons/com.apple.postfix.master.plist
if you get any error like for example “invalid property” means there’s a problem with plist. Once successful, simply go through the process of re-enable SIP.

Step 5.) Send test mail

To send a test mail in terminal use the following comand with the recipient email or your choice:
 $>echo "Postfix setting test" | mail -s "Hello Postfix" [email protected]
Some other useful commands
  • mailq Check mails in the queue and errors if mail not sent.
  • sudo postfix flush Flush the queue.
  • sudo postsuper -d Delete all mails in the queue.
  • sudo rm /var/mail/$USER Remove all mails from local host.
  • sudo postfix start Start postfix mail system.
  • sudo postfix stop Stop postfix mail system.
  • sudo postfix reload Reload postfix mail system.

Tags:Apple, Mac OS, MacOS tutorial

No comments
Back to top