manuel
Posted on October 14, 2018
Populate /etc/mail/aliases
echo "root: YOUR_LOCAL_USER" >> /etc/mail/aliases
That means that all emails sent to root are going to YOUR_LOCAL_USER.
If you want you can add some other aliases, like “contact” or “hi”.
echo "contact: YOUR_LOCAL_USER" >> /etc/mail/aliases
echo "hi: YOUR_LOCAL_USER" >> /etc/mail/aliases
After we add all our aliases it’s necessary to run newaliases
.
newaliases
/etc/mail/aliases: 70 aliases
Now you should create an SSL certificate like here or use an existing one.
Now we can populate /etc/mail/smtpd.conf
and replace example.com with your domain. Everything we want is to receive emails from other for local users and deliver all emails to users mbox => /var/mail/YOUR_LOCAL_USER
table aliases file:/etc/mail/aliases
pki example.com key "/path/to/your/example.com.key"
pki example.com certificate "/path/to/your/exmaple.com.crt"
listen on egress tls pki exmaple.com
listen on egress port 587 hostname example.com tls-require pki example.com auth mask-source
accept from any for domain "example.com" alias <aliases> deliver to mbox
accept from any for local alias <aliases> deliver to mbox
accept from local for any relay
That’s it. OpenSMTPD is listen on port 25 and 587 and accept encrypted connections. The key and certificate location are configured with the pki keyword. And the messages are delivered to system mbox of the user (/var/mail/YOUR_LOCAL_USER).
Populate /etc/mail/mailname
with your domain.
echo "example.com">/etc/mail/mailname
Now you can check you configuration smtpd -n
and when everything looks ok, you can restart OpenSMTPD rcctl restart smtpd
Check your OpenSMTPD server with telnet
telnet exmaple.com
EHLO exmaple.com
MAIL FROM: <from@somehwere.tld>
RCPT TO: <to@example.com>
DATA
Subject: This is just a test
<- blank line ->
This is a test :)
<- blank line ->
.
QUIT
If it’s says something like 250 2.0.0: 574eff74 Message accepted for delivery
, congratulation OpenSMTPD works.
Posted on October 14, 2018
Join Our Newsletter. No Spam, Only the good stuff.
Sign up to receive the latest update from our blog.