dovecot 是一个开源的IMAP和POP3邮件服务器 收件协议 (SMTP 传输发件)
POP/IMAP 是MUA从邮件服务器中读取邮件时使用的协议。其中,与POP3是从邮件服务器中下载邮件存起来,IMAP则是将邮件留在服务器端直接对邮件进行管理、操作。
dovecot 可以被其他具有相同功能的软件替代,比如:cyrus-imapd。
安装;
yum install dovecot dovecot-devel dovecot-mysql pam-devel -y
2、dovecot 文件配置
dovecot 配置参考
# cat dovecot.conf
protocols = imap pop3 listen = * # 日志目录 info_log_path = /var/log/dovecot-info.log debug_log_path = /var/log/dovecot-debug.log dict { #quota = mysql:/etc/dovecot/dovecot-dict-sql.conf.ext #expire = sqlite:/etc/dovecot/dovecot-dict-sql.conf.ext } !include conf.d/*.conf !include_try /etc/dovecot/local.conf
# dovecot-sql.conf.ext 下面自己创建编辑 passdb { driver = sql args = /etc/dovecot/dovecot-sql.conf.ext } # wmail 为前面创建的邮箱专用账户 userdb { driver = static args = uid=5000 gid=5000 home=/home/wmail/%d/%n } ####调试日志 auth_debug_passwords=yes mail_debug=yes auth_verbose=yes auth_verbose_passwords=plain
3、配置 dovecot 日志文件
需要 设置下权限 否则日志权限报错
(mail dovecot: lda: Fatal: Can't open log file /var/log/dovecot-info.log: Permission denied)
# chown dovecot /var/log/dovecot-*.log # chmod 777 /var/log/dovecot-*.log
4、auth 认证 配置 参考:
# cat conf.d/10-auth.conf disable_plaintext_auth = no auth_mechanisms = plain login cram-md5 !include auth-system.conf.ext
5、10-ssl.comf 配置参考
10-ssl.conf文件主要是关于postfix的ssl认证相关的配置
ssl 先禁止用;
# cat conf.d/10-ssl.conf
ssl = no
6、10-mail.conf 文件配置参考
10-mail.conf 文件主要定义邮件用户存储相关信息的位置
# cat conf.d/10-mail.conf
mail_location = maildir:/home/wmail/%d/%n/Maildir mbox_write_locks = fcntl
7、10-master.conf 配置参考
10-master.conf文件定义了dovecot的pop3和imap端口
设置 auth-userdb 为之前创建的 postfix 专用用户 wmail
# cat conf.d/10-master.conf |grep -v ^$ |grep -v ^#
service imap-login { inet_listener imap { port = 143 } } service pop3-login { inet_listener pop3 { port = 110 } } service auth { unix_listener auth-userdb { mode = 0600 user = wmail group = wmail } # Postfix smtp-auth unix_listener /var/spool/postfix/private/auth { mode = 0666 } # Auth process is run as this user. #user = $default_internal_user }
8、15-lda.conf 文件
修改15-lda.conf文件,是为了防止dovecot异常报错。 # cat conf.d/15-lda.conf
postmaster_address = postmaster@example.com
9、在 /etc/dovecot/ 下创建 dovecot-sql.conf.ext 文件。
配置 mysql 链接信息。
# cat dovecot-sql.conf.ext driver = mysql connect = host=localhost dbname=postfix user=postfix password=postfix default_pass_scheme = MD5-CRYPT password_query = SELECT username AS user,password FROM mailbox WHERE username = '%u' AND active='1' user_query = SELECT maildir, 5000 AS uid, 5000 AS gid, CONCAT('dict:storage=',floor(quota/1000),' proxy::quota') as quota FROM mailbox WHERE username = '%u' AND active='1'
10、启动dovecot
/etc/init.d/dovecot start chkconfig dovecot on 防止服务冲突 请关闭 portreserve /etc/init.d/portreserve stop chkconfig portreserve off
11、测试 dovecot
还可以 ss -tln 检测 110 143 端口存活
telnet mail.wangxiaojing.com 110 telnet mail.wangxiaojing.com 143 出现+Ok Dovecot ready,则表示dovecot配置正确。