Relay mail to GMail with OpenBSD

Using Postfix

postfix logo

Install packages

pkg_add postfix-<ver>-sasl2

Setup mailer.conf

/usr/local/sbin/postfix-enable

Configure /etc/postfix/main.cf. Add the following ...

relayhost = [smtp.gmail.com]:587
smtp_sasl_auth_enable = yes
smtp_sasl_password_maps = hash:/etc/postfix/sasl_passwd
smtp_sasl_security_options = noanonymous
smtp_tls_CAfile = /etc/postfix/cacert.pem
smtp_use_tls = yes

Put gmail login in /etc/postfix/sasl_passwd

[smtp.gmail.com]:587    user.name@gmail.com:password

Map sasl password

sudo chmod 400 /etc/postfix/sasl_passwd
sudo postmap /etc/postfix/sasl_passwd

Install a root certificate to /etc/postfix/cacert.pem

Start or reload postfix.

postfix start

Using smtpd

opensmtpd logo

Using the guide from bsdnow.tv I got this working.

Reference