Mail Configuration With Dovecot and Postfix

Two services for Dovecot

  1. IMAP for dovecot to communicate with your mail client.
  2. LMTP for dovecot to communicate with postfix server running on the same machine.

Don't touch dovecot.conf

Rather put all your configuration in /etc/dovecot/local.conf. This one is called from dovecot.conf and anything you put there will be safe from future software updates.


You will find the following line in /etc/dovecot/local.conf

!include_try local.conf

/etc/dovecot/local.conf

protocols = imap lmtp
auth_verbose = no
auth_mechanisms = plain login
mail_home = /web/mail/%d/%n
mail_location = maildir:~/mail/
mail_uid = habib
mail_gid = habib
first_valid_uid = 8


# wild card codes :
# %u = habib@habibur.com
# %n = habib
# %d = habibur.com

passdb {
driver = passwd-file
args = scheme=plain username_format=%u /etc/dovecot/mailusers
}


userdb {
driver = static
}

Protocols IMAP / LMTP

The first line of local.conf
protocols = imap lmtp

IMAP for client communication. LMTP for communicating with the postfix server.

/etc/dovecot/mailuser

habib@habibur.com:mypassword
mail@habibur.com:::::::user=habib@habibur.com nonauthenticated

File showing real user and alias configuration.

Mail directory

/web/mail/habibur.com/habib/mail/[cur|new|tmp]

That is, domain / username is home and then a mail/ folder inside it for Maildir files.

/etc/postfix/config.d/10-master.conf

service auth {
	unix_listener /var/spool/postfix/private/auth {
	 user=habib
	group=habib
	mode = 0666
	}
}

And also this file,

service lmtp {
	unix_listener /var/spool/postfix/private/dovecot {
	mode = 0666
	user = postfix
	group = postfix
	}
}

Disable the default PAM

Edit file auth-system.conf.ext and comment out these block at the top.


#passdb {
# driver = pam
	# [session=yes] [setcred=yes] [failure_show_msg=yes] [max_requests=<n>]
	# [cache_key=<key>] [<service name>]
	#args = dovecot
#}

Comment out this whole passdb = pam block. You won't need this.

Add the certificates

You will find the file in /etc/dovecot/conf.d/10-ssl.conf

ssl_cert = </etc/letsencrypt/live/habibur.com/fullchain.pem
ssl_key = </etc/letsencrypt/live/habibur.com/privkey.pem
Published
11-Oct-2022
Updated
11-Oct-2022