A simple relay via OpenSMTPD
02 Mar 2017
Using OpenSMTPD as a relay
through your favorite email service provider is quite an easy setup.
The first step is to of course install OpenSMTPD and OpenSMTPD-extras.
Do make sure to go through the
quite informative and useful.
The second thing we will need are the credentials to the email
service provider which are referenced under OpenSMTPD's configuration
file. The credentials file
/etc/mail/secrets holds the
user name and password, along with a label of your choosing.
The final step would be to edit OpenSMTPD's main configuration
smtpd.conf file like so:
# Table setup
table aliases file:/etc/mail/aliases
table passwd file:/etc/mail/secrets
# To accept external mail, replace with: listen on all
listen on lo0
# Accept local messages
accept for local alias deliver to mbox
accept for any relay via tls+auth://email@example.com \
auth as "firstname.lastname@example.org"
To make sure there are no syntax issues in the configuration file,
run the following command:
$ smtpd -n
You may check to make sure it is working through the terminal with
the mail command:
$ echo "Message" | mail -s "Subject" email@example.com
One last tip depending on your needs, do make sure the
GECOS field is
properly configured for your local account.