Deliver macOS system mail
Deliver macOS system mail with the following instructions. These instructions apply to macOS Catalina.
Why would you want to do this?
- You have cron jobs running on your system, and you want to receive emails when they fail
- You want to send an email when certain things happen on your system through Automator or other means
Edit the /etc/postfix/sasl_passwd file
sudu vi /etc/postfix/sasl_passwd
Add this line of text
[smtp.gmail.com]:587 <Your Email Id>@gmail.com:<Your Password>
Run this command
sudo postmap /etc/postfix/sasl_passwd
Edit the sudo vi /etc/postfix/main.cf file
sudo vi /etc/postfix/main.cf
Check that none of these settings are defined in the file then add these settings to the bottom of the file.
# Gmail SMTP relay relayhost = [smtp.gmail.com]:587 # Enable SASL authentication in the Postfix SMTP client. smtpd_sasl_auth_enable = yes smtp_sasl_auth_enable = yes smtp_sasl_password_maps = hash:/etc/postfix/sasl_passwd smtp_sasl_security_options = smtp_sasl_mechanism_filter = AUTH LOGIN # Enable Transport Layer Security (TLS), i.e. SSL. smtp_use_tls = yes smtp_tls_security_level = encrypt tls_random_source = dev:/dev/urandom
Test delivery of mail from your system
date | mail -s "Test Email" <Your Email Id>@gmail.com
If you don’t receive an email you can run this command before the previous command to debug the problem.
log stream --predicate '(process == "smtpd") || (process == "smtp")' --info