Title : Configure OpenSMTPD to relay on a network
Author: Solène
Date  : 29 October 2018
Tags  : openbsd68 highlight opensmtpd

With the new OpenSMTPD syntax change which landed with OpenBSD 6.4
release, changes are needed for making opensmtpd to act as a lan relay
to a smtp server. This case wasn't covered in my previous article
about opensmtpd, I was only writing about relaying from the local
machine, not for a network. Mike (a reader of the blog) shared that it
would be nice to have an article about it. Here it is! :)

A simple configuration would look like the following:

    listen on em0
    listen on lo0
    table aliases db:/etc/mail/aliases.db
    table secrets db:/etc/mail/secrets.db
    action "local" mbox alias <aliases>
    action "relay" relay host smtps://myrelay@remote-smtpd.tld auth <secrets>
    match for local action "local"
    match from local for any action "relay"
    match from src for action relay

The daemon will listen on em0 interface, and mail delivered from the
network will be relayed to remote-smtpd.tld. 

For a relay using authentication, the login and passwords must be
defined in the file **/etc/mail/secrets** like this: `myrelay

[smtpd.conf(5)](http://man.openbsd.org/smtpd.conf) explains creation
of **/etc/mail/secrets** like this:

    touch /etc/mail/secrets
    chmod 640 /etc/mail/secrets
    chown root:_smtpd /etc/mail/secrets