Email service configuration on Mac
These instructions explain how to setup an automatic email sending functionality on Mac. This service can
be called programmatically. The example uses gmail as an email box, but all other email boxes can be used as well.
Navigate to the Mac OS directory
/etc/postfix/
and edit a file main.cf. Open it with the command
$ sudo nano main.cf
and add the following lines to the main.cf
# new additions here
compatibility_level=2
# Minimum Postfix-specific configurations.
mydomain_fallback = localhost
mail_owner = _postfix
setgid_group = _postdrop
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/sasl_passwd
smtp_sasl_security_options=
# Enable Transport Layer Security (TLS), i.e. SSL.
smtp_use_tls=yes
smtp_tls_security_level=encrypt
tls_random_source=dev:/dev/urandom
Create a file sasl_passwd and place it into the /etc/postfix/ -folder
$ sudo nano sasl_passwd
and add a line
smtp.gmail.com:587 your_gmail_address:password
Restart the postfix service
$ sudo postmap /etc/postfix/sasl_passwd
$ sudo postfix stop
$ sudo postfix start
Now the email service should be ready to use. You may test the service with the command
$ echo 'Hello World!' | mail -s testing your_gmail_address
Back to the
main page.