主配置文件 /usr/local/etc/dovecot/dovecot.conf
# Protocols we want to be serving.
protocols = imap pop3 lmtp
# A comma separated list of IPs or hosts where to listen in for connections.
# "*" listens in all IPv4 interfaces, "::" listens in all IPv6 interfaces.
# If you want to specify non-default ports or anything more complex,
# edit conf.d/master.conf.
listen = *
认证文件 /usr/local/etc/dovecot/conf.d/10-auth.conf
disable_plaintext_auth = no
auth_mechanisms = plain login
#!include auth-system.conf.ext
!include auth-sql.conf.ext
ssl配置文件 /usr/local/etc/dovecot/conf.d/10-ssl.conf 设置为no,注释掉ssl_cert,如要启用,则要创建ssl_key
ssl = no
#ssl_cert = </etc/ssl/certs/dovecot.pem
#ssl_key = </etc/ssl/private/dovecot.pem
日志文件 /usr/local/etc/dovecot/conf.d/10-logging.conf 指定的日志文件记得给权限,我指定的777
log_path = /var/log/dovecot.log
auth_debug = yes
mail_debug = yes
邮箱配置 /usr/local/etc/dovecot/conf.d/10-mail.conf uid和gid是开始建立的postfix的id
mail_home = /home/xmail/%d/%n
mail_location = maildir:~/Maildir
first_valid_uid = 1010
first_valid_gid = 1010
配合postfix /usr/local/etc/dovecot/conf.d/10-master.conf
unix_listener auth-userdb {
mode = 0600
user = tmail
group = tmail
}
# Postfix smtp-auth
unix_listener /var/spool/postfix/private/auth {
mode = 0666
user = postfix
group = postfix
}
指定sql配置文件 /usr/local/etc/dovecot/conf.d/auth-sql.conf.ext
passdb {
driver = sql
# Path for SQL configuration file, see example-config/dovecot-sql.conf.ext
args = /usr/local/etc/dovecot/dovecot-sql.conf.ext
}
userdb {
driver = sql
args = /usr/local/etc/dovecot/dovecot-sql.conf.ext
}
mysql配置文件 /usr/local/etc/dovecot/dovecot-sql.conf.ext
driver = mysql
connect = host=localhost dbname=postfix user=root password=123456
default_pass_scheme = MD5
password_query = \
SELECT username,password \
FROM mailbox WHERE username = '%u' AND active = '1'
##下面的1020 是指邮件存储目录的uid gid
user_query = \
SELECT maildir,1020 AS uid,1020 AS gid \
FROM mailbox WHERE username = '%u' AND active = '1'
邮箱目录 /usr/local/etc/dovecot/conf.d/15-mailboxes.conf
##
## Mailbox definitions
##
# NOTE: Assumes "namespace inbox" has been defined in 10-mail.conf.
namespace inbox {
#mailbox name {
# auto=create will automatically create this mailbox.
# auto=subscribe will both create and subscribe to the mailbox.
#auto = no
# Space separated list of IMAP SPECIAL-USE attributes as specified by
# RFC 6154: \All \Archive \Drafts \Flagged \Junk \Sent \Trash
#special_use =
#}
# These mailboxes are widely used and could perhaps be created automatically:
mailbox Drafts {
auto = subscribe
special_use = \Drafts
}
mailbox Junk {
auto = subscribe
special_use = \Junk
}
mailbox Trash {
auto = subscribe
special_use = \Trash
}
# For \Sent mailboxes there are two widely used names. We'll mark both of
# them as \Sent. User typically deletes one of them if duplicates are created.
mailbox Sent {
auto = subscribe # autocreate and autosubscribe the Sent mailbox
special_use = \Sent
}
mailbox "Sent Messages" {
special_use = \Sent
}
# If you have a virtual "All messages" mailbox:
mailbox virtual/All {
special_use = \All
}
# If you have a virtual "Flagged" mailbox:
mailbox virtual/Flagged {
auto = subscribe
special_use = \Flagged
}
}