We all know SPAM emails are a big problem. As a result, many email services keep a close eye on emails to see if they're legitimate. In Derek's Tech Independence guide, he outlines how to setup an SMTP server in a simple way, which is very helpful. But, if you're planning on using your server long term, you'll likely need to take some extra steps.
One major issue is that Gmail will automatically block emails from your personal mail server unless you take one of two actions: set up an SPF record or enable DKIM signing. If you only want to do the bare minimum, it's easier to just set up the SPF record. But, it's highly recommended that you enable both and also set up a DMARC record. By doing all of this, it's less likely that your email will be marked as spam by different email providers.
The instructions below assume you have followed Derek's guide exactly.
Type:
” to “TXT - Text record”.Host:
” blank.Answer:
” type v=spf1 mx -all
@
under 'Host' field, type v=spf1 mx -all
under 'Value' field, and click the green check on the right side of the row.doas su
pkg_add opensmtpd-filter-dkimsign
cd /etc/mail
mkdir dkim
openssl genrsa -out /etc/mail/dkim/example.com.key 2048
example.com
with your domain.openssl rsa -in /etc/mail/dkim/example.com.key -pubout -out /etc/mail/dkim/example.com.pub
example.com
with your domain (notice two mentions of example.com
)./etc/mail/dkim
.chown -R _smtpd dkim
chmod -R 700 dkim
/etc/mail/smtpd.conf
in vi or other remote editor on server.filter "dkimsign" proc-exec "filter-dkimsign -d example.com -s mail -k /etc/mail/dkim/example.com.key -c relaxed/relaxed"
example.com
with your domain (note there are two spots to replace). filter "dkimsign"
rcctl restart smtpd
more /etc/mail/example.com.pub
example.com
with your domain.-----BEGIN PUBLIC KEY-----
and -----END PUBLIC KEY-----
markers and paste it into a new text file (NotePad or TextEdit).Type:
” to “TXT - Text record”.Host:
” type mail._domainkey
Answer:
” type v=DKIM1;k=rsa;p=*PUBLIC_KEY*
*PUBLIC_KEY*
with the content of the text file created in steps 17 and 18.Type:
” to “TXT - Text record”.Host:
” type _dmarc
Answer:
” type v=DMARC1; p=quarantine; rua=mailto:email@example.com
email@example.com
with an email address where you want to get delivery reports. I recommend creating a separate account for this.