OpenSMPTD Relay
Forwarding mail from other servers is perhaps the first task you may want to take up with smptd(8). Building systems configuration is somewhat like programming: build it up incrementally. rset(1) plus entr(1) allow you to quickly interate on a configuration task by adding one feature at a time.
SMTP Relay
The following rules configure a certificate and accept delivery for a domain
# /etc/mail/smtpd.conf table aliases file:/etc/mail/aliases listen on localhost port 25 listen on egress port 25 action "mbox" mbox alias <aliases> action "relay" relay match for local action "mbox" match auth from any for any action "relay" # match local accounts
Apply using the following fomula
# relay.pln mail: → ./rinstall vm/smtpd.conf /etc/mail/smtpd.conf && rcctl restart smtpd → newaliases > /dev/null
To accept responsibility for incoming mail for a domain, add
match from any for domain sidecomment.io action "mbox"
To to accept messages for others servers on our network, add
table trusted { 66.42.118.218 } match from src <trusted> for any action "relay"
Forwarding
Hosts that will be using our new relay can still accept mail for localhost, but forward everything else through our new relay
# /etc/mail/smtpd.conf table aliases file:/etc/mail/aliases listen on socket listen on localhost action "mbox" mbox alias <aliases> action "outbound" relay host smtp://45.76.230.117:25 match from local for local action "mbox" match from local for any action "outbound"
Finally, run a test and observe log output
echo "123" | mail -r [email protected] -s 'test message' [email protected]