amazon-web-servicesamazon-sesopensmtpd

How to configure OpenSMTPD with Amazon SES?


Amazon has instructions for postfix and sendmail, but not OpenSMTPD, so adding them here.


Solution

  • Tested with OpenBSD 5.8

    1. Verify your domain and a sender in AWS SES console. Save your SMTP Settings.

    2. Set up the SMTP authentication details in the mail secrets database (replacing $smtpUsername:$smtpPassword with the values from step 1)

      # touch /etc/mail/secrets
      # chmod 640 /etc/mail/secrets
      # chown root:_smtpd /etc/mail/secrets
      # echo "ses $smtpUsername:$smtpPassword" >> /etc/mail/secrets
      # makemap /etc/mail/secrets
      
    3. Configure OpenSMTPD:

      # nano /etc/mail/smtpd.conf
      
      listen on lo0
      table aliases db:/etc/mail/aliases.db
      table secrets db:/etc/mail/secrets.db
      accept for local alias <aliases> deliver to mbox
      accept from local for any relay via tls+auth://ses@email-smtp.us-east-1.amazonaws.com auth <secrets>
      
    4. Restart OpenSMTPD:

      # rcctl restart smtpd
      
    5. Test it:

      # sendmail -v -f verified-sender@verified-domain.com to@example.com
      Subject: test subject
      
      test body
      ^D
      

    Errors?

    watch your line-breaks in smtpd.conf

    # smtpd -n to check for syntax errors in smtpd.conf

    Try port 587 if your machine is blocking port 25 (add :587 to end of aws url in smtpd.conf)