notes from mnlwldr

Thoughts about programming and other things I want to share

@mnlwldr on Twitter @mnlwldr on GitHub @mnlwldr on Mastodon

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.

/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 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 key "/path/to/your/"
pki certificate "/path/to/your/"

listen on egress tls pki
listen on egress port 587 hostname tls-require pki auth mask-source

accept from any for domain "" 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 "">/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

MAIL FROM: <from@somehwere.tld>
Subject: This is just a test
<- blank line ->
This is a test :)
<- blank line ->

If it’s says something like 250 2.0.0: 574eff74 Message accepted for delivery, congratulation OpenSMTPD works.

Have you written a response to this? Let me know the URL