OpenSMTPD forward to Google

From Aram's Wiki
Jump to: navigation, search


Introduction

We'll use OpenSMTPD to forward to Google.

Prerequisites

A Gmail/Google Apps account. OpenSMTPD is already installed and running on OpenBSD.

How

Enable access to what Google calls less secure apps.

Then as root:

echo "googlemail user@gmail.com:password" > /etc/mail/secrets

You can use your Google Apps username instead of gmail, and googlemail is just a label that we will use later.

In /etc/mail/smtpd.conf:

table aliases file:/etc/mail/aliases
table secrets db:/etc/mail/secrets.db

listen on lo0

action "local" mbox alias <aliases>
action "relay" relay host smtp+tls://googlemail@smtp.googlemail.com:587 auth <secrets>

match for local action "local"
match for any action "relay"

Notice the googlemail label.

Then just restart smtpd:

rcctl restart smtpd

Test

echo "Does it work?" | mail -s "Mail test from OpenBSD" spam@mgk.ro