A mail server in 10 minutes

I you're in a hurry, here is a quick setup to have a working email server. It will also be a good starting point to build on later. With the following :

Later, we'll discuss virtual users to fix these minor issues. But here, we're in a rush so let's go! 😊

smtpd.conf file

Edit /etc/mail/smtpd.conf :

# Generic config
## Tables 
table aliases "/etc/mail/aliases"
## Certificates
pki athome.tld key "/etc/ssl/private/athome.tld.key"
pki athome.tld cert "/etc/ssl/athome.tld.crt"
### Get messages
listen on all tls pki athome.tld 
### To send with mail client
listen on all port submission tls-require pki athome.tld auth 
# ACTIONS
action "sendthismail" relay 
## System aliases
action local_maildir maildir alias <aliases>
## Deliver in maildir
action in_maildir maildir 
## Get
### From system to local users
match for local action local_maildir
### deliver remote messages for users if match the domain
match from any for domain "athome.tld" action in_maildir
## Sending
match for any action "sendthismail"
match auth from any for any action "sendthismail"

That's it 😊

There a almost more comments than reals instructions.

Dovecot configuration (IMAP)

Install dovecot : "# pkg_add dovecot".

In "/etc/dovecot/local.conf" add :

# listen on IPV4 and IPV6.
listen = *, [::]
# We use Maildir
mail_location = maildir:~/Maildir
# imap > pop
protocols = imap
# Safety. Edit those lines !
ssl = yes
ssl_cert = </etc/ssl/athome.tld.crt
ssl_key = </etc/ssl/private/athome.tld.key
disable_plaintext_auth = yes
# auth methods
passdb {
        driver = bsdauth
}
userdb {
        driver = passwd
}

Reload dovecot : "# rcctl restart dovecot".

Here you go, it's done, you can configure your mail client.