Set Up macOS to Use Postfix for Sending Automated Emails from CRON

Looking to automate email notifications from your macOS using CRON jobs? This guide will walk you through configuring Postfix on a macOS to send emails from CRON jobs to a designated email address.


  • Access to a macOS computer

  • Basic knowledge of terminal commands

  • An email account with SMTP access (we'll use Gmail as an example)

Step 1: Verify Postfix Installation

Check if Postfix is installed on your macOS:

postconf -d | grep mail_version

You should see output similar to this:

mail_version = 3.2.2
milter_macro_v = $mail_name $mail_version

Step 2: Configure Postfix

  1. Edit the main configuration file:

    Open /etc/postfix/ with superuser privileges:

     sudo vi /etc/postfix/

    Configure the following settings:

    • Set up your SMTP server and port. For Gmail, use port 465:

        relayhost = []:465
    • Enable SASL authentication:

        smtp_sasl_auth_enable = yes
    • Specify the path to the SASL password file:

        smtp_sasl_password_maps = hash:/etc/postfix/sasl_passwd
    • Set security options:

        smtp_sasl_security_options = noanonymous
    • Enable TLS and set the security level:

        smtp_use_tls = yes
        smtp_tls_security_level = encrypt
        smtp_tls_note_starttls_offer = yes
    • Enable TLS wrapper mode:

        smtp_tls_wrappermode = yes
    • Define your domain:

        mydomain =
        myorigin = $mydomain

Step 3: Create the SASL Password File

  1. Create the sasl_passwd file:

     sudo vi /etc/postfix/sasl_passwd

    Add your SMTP credentials:


    Regardless of the email address you enter CRON always sends emails from username@domain.tld, where username is the user under which CRON is running.

  2. Secure and hash the password file:

     sudo postmap /etc/postfix/sasl_passwd
     sudo chmod 600 /etc/postfix/sasl_passwd /etc/postfix/sasl_passwd.db
  3. Reload Postfix to apply the changes:

     sudo postfix reload

    If you get this error:

     postfix/postfix-script: fatal: the Postfix mail system is not running

    then you need start Postfix:

     sudo postfix start

Step 4: Testing

You can test your CRON jobs with something like this:

* * * * * echo "Hello, this is a test from CRON" | sendmail
* * * * * bash /path/to/invalid/script

Replace with the email address where you want to send the output.


  • If emails aren't being received, check the Postfix log for errors:

      log stream --predicate  '(process == "smtpd") || (process == "smtp")' --info --debug
  • Verify the sender email is authorized to send through the SMTP server.


You've now configured your macOS to send automated emails from CRON jobs using Postfix, enhancing your productivity and monitoring capabilities.