Dovecot

Prerequisite
You will need to have setup Let’s Encrypt before going to this guide.

Create System User
User vmail will be used to store mail related data

If the command complains about the UID or GID being in use, just increment the number. It can be anything between 500 and 999.

Activate
Edit file  and make sure the only included authentication mechanism is passwdfile.

Edit file  and set option

Create file

Add a User
First generate an encrypted password for the user

Now add a line to

Mail Storage
Configuration of the mail storage is done in

Enable
To enable sieve filters during mail delivery, edit file  and uncomment/modify the following lines

ManageSieve
The manageSieve allows you mail client to set and modify the sieve scripts on your server. To enable it, uncomment/modify the following lines in  If you change default port, don't forget to change it in the firewall configuration bellow.

Firewall
You will need to open 2 ports in your firewall:
 * for imap
 * for managesieve (if enabled above)

Generate Certificate
This part assume that you've setup Let’s Encrypt.

Add your domain to

Add your new certificate to

And finally generate the certificate

Configure
Edit file  and change the following settings

Limits
By default dovecot limit IMAP connections to 10 per IP and per user. Given that each email client can use multiple connections and that you might have multiple devices at home, it is quite easy to reach the limit.

On a server with few users, it is safe to raise the limit. To do so, edit  in file

Fail2Ban
Create file  with the following content