Dovecot is an open source IMAP and POP3 email server for Linux/UNIX-like systems, written with security primarily in mind. Dovecot is an excellent choice for both small and large installations. It’s fast, simple to set up, requires no special administration and it uses very little memory.
On writing this tutorial, we are imagining you have a basic linux box running
We have tested this settings mostly on Debian based operating system, Debian8 and Ubuntu 16.04

Incase of any difficulties please drop us a comment below and we will revert to you in a short while

Let’s start by installing all the necessary dovecot packages

By the way, if you don’t have mysql already installed. You can follow this link MySQL 5.x Installation on Debian 8 on how to install it

Now lets continue to Dovecot 2.2 Configurations to work with Mysql
First of all we will make a backup copy of the files that we will edit so that when we messup we can revert back to the original and refer what could be the issue

Now lets start by creating a new file  /etc/dovecot/dovecot-sql-conf.ext   and add the following configurations

We are also imagining that you have a system user vmail created on your linuxbox, if not use the two commands to create them

Edit Another file /etc/dovecot/conf.d/10-mail.conf and fine the text in red, match them accordingly

Now lets edit file /etc/dovecot/conf.d/10-ssl.conf, find the text in red and match them accordingly

Edit another file /etc/dovecot/conf.d/10-auth.conf and change the settings of the file as shown below

Edit file /etc/dovecot/conf.d/10-mail.conf

Edit file /etc/dovecot/conf.d/10-ssl.conf

Edit file /etc/dovecot/conf.d/10-master.conf

Now lets give a proper permission to our files

Restart Dovecot for the changes to take effect

Thats it !!!!!!!!!!!!!!! Try to login using a virtual user and see if its working
If you face any difficulties please dont hesitate to drop us a comment,
Also we will keep updating this post, if we see any new better changes, please keep visiting