2012-10-26
Postfix Sasl Dovecot
How to setup Postfix with Maildir delivery, authentify against Dovecot, and get SSL imap
1 postfix
- install postfix and dovecot
apt-get install postfix dovecot-imapd dovecot-common
- select internet site
- /etc/postfix/main.cf
mydestination = mydomain.com # CUSTOM virtual_mailbox_domains = mydomain.com domain.com virtual_mailbox_base = /var/mail/vhosts virtual_mailbox_maps = hash:/etc/postfix/vmailbox virtual_minimum_uid = 100 virtual_uid_maps = static:5000 virtual_gid_maps = static:5000 virtual_alias_maps = hash:/etc/postfix/virtual inet_protocols = ipv4 home_mailbox = Maildir/ mailbox_command = ""
- /etc/postfix/virtual
postmaster@domain.com user@mydomain.com
- /etc/postfix/vmailbox
user@mydomain.com mydomain.com/user/ #Maildir folder
- add vmail user and group
addgroup --gid 5000 vmail adduser --home /var/mail/vhosts --uid 5000 --gid 5000 --disabled-login vmail sudo -u vmail mkdir /var/mail/vhosts/mydomain.com
=> incoming OK => sending KO
2 auth against Dovecot
- /etc/postfix/main.cf
## dovecot auth smtpd_sasl_type = dovecot smtpd_sasl_path = private/auth smtpd_sasl_auth_enable = yes smtpd_recipient_restrictions = permit_sasl_authenticated,permit_mynetworks,reject_unauth_destination
- /etc/dovecot/conf.d/10-auth.conf
100:auth_mechanisms = plain login digest-md5 122:#!include auth-system.conf.ext 128:!include auth-static.conf.ext
- /etc/dovecot/conf.d/auth-static.conf.ext
userdb { driver = static args = uid=vmail gid=vmail home=/var/mail/vhosts/%d/%n } passdb { driver = passwd-file args = scheme=MD5-CRYPT username_format=%u /etc/dovecot/users }
- /etc/dovecot/user
#http://wiki.dovecot.org/AuthDatabase/PasswdFile #md5pass mypassword myuser:{md5-crypt}$1$h1TS0YZx$pVCUTfU2JzojtsN3BnsJz0
- disable 143 in /etc/dovecot/10-master.conf
service imap-login { inet_listener imap { port = 0 } inet_listener imaps { port = 993 ssl = yes }
- set auth socket for postfix in /etc/dovecot/10-master.conf
service auth { unix_listener /var/spool/postfix/private/auth { mode = 0660 user=postfix group=postfix } }