一。软件安装
-
#apt-get install postfix postfix-ldap dovecot-common dovecot-pop3d dovecot-imapd
二。建立邮件账户
-
#groupadd -g 1001 vmail
-
#useradd -u 1001 -g 1001 -s /usr/sbin/nologin vmail
二。postfix配置
-
#postconf -n
-
alias_database = hash:/etc/aliases
-
alias_maps = hash:/etc/aliases
-
append_at_myorigin = no
-
append_dot_mydomain = no
-
biff = no
-
broken_sasl_auth_clients = yes
-
config_directory = /etc/postfix
-
dovecot_destination_recipient_limit = 1
-
ignore_mx_lookup_error = yes
-
inet_interfaces = all
-
inet_protocols = ipv4
-
mailbox_size_limit = 524288000
-
message_size_limit = 31457280
-
mydomain = example.com
-
myhostname = mail.example.com
-
mynetworks = 0.0.0.0/0
-
myorigin = $mydomain
-
readme_directory = no
-
recipient_delimiter = +
-
smtp_tls_note_starttls_offer = yes
-
smtp_use_tls = yes
-
smtpd_banner = $mydomain ESMTP MAIL SYSTEM
-
smtpd_helo_required = yes
-
smtpd_recipient_restrictions = permit_sasl_authenticated, reject_unauth_destination, reject_non_fqdn_hostname, reject_non_fqdn_sender, reject_non_fqdn_recipient, reject_unauth_pipelining, reject_invalid_hostname
-
smtpd_sasl_auth_enable = yes
-
smtpd_sasl_local_domain = $mydomain
-
smtpd_sasl_path = private/auth
-
smtpd_sasl_security_options = noanonymous
-
smtpd_sasl_type = dovecot
-
smtpd_sender_login_maps = ldap:/etc/postfix/ldap-users.cf
-
smtpd_sender_restrictions = permit_sasl_authenticated,reject_unknown_sender_domain,reject
-
smtpd_tls_CAfile = /etc/postfix/ssl/certs/cacert.pem
-
smtpd_tls_auth_only = no
-
smtpd_tls_cert_file = /etc/postfix/ssl/certs/smtpd.crt
-
smtpd_tls_key_file = /etc/postfix/ssl/private/smtpd.key
-
smtpd_tls_loglevel = 1
-
smtpd_tls_received_header = yes
-
smtpd_tls_session_cache_timeout = 3600s
-
tls_random_source = dev:/dev/urandom
-
virtual_gid_maps = static:1001
-
virtual_mailbox_base = /data/vmail
-
virtual_mailbox_domains = example.com
-
virtual_mailbox_maps = ldap:/etc/postfix/ldap-users.cf
-
virtual_transport = dovecot
-
virtual_uid_maps = static:1001
ldap-users.cf配置
192.168.1.100是我的AD服务器
-
server_host = 192.168.1.100
-
search_base = dc=example,dc=com
-
version=3
-
query_filter = (&(objectclass=person)(|(sAMAccountName=%u)(othermailbox=%s))(!(userAccountControl=66050)))
-
bind = yes
-
bind_dn = vmail@example.com
-
bind_pw = 1234567
-
result_attribute = sAMAccountName
-
result_format = /data/vmail/%u/Maildir/
四。dovecot配置
-
#dovecot -n
-
# 2.0.19: /etc/dovecot/dovecot.conf
-
# OS: Linux 3.2.0-29-generic x86_64 Ubuntu 12.04.1 LTS ext3
-
auth_debug = yes
-
auth_debug_passwords = yes
-
auth_mechanisms = plain login
-
disable_plaintext_auth = no
-
info_log_path = /var/log/dovecot-info.log
-
listen = *
-
log_path = /var/log/dovecot.log
-
mail_gid = vmail
-
mail_location = maildir:/data/vmail/%u/Maildir
-
mail_uid = vmail
-
passdb {
-
driver = pam
-
}
-
passdb {
-
args = /etc/dovecot/dovecot-ldap.conf.ext
-
driver = ldap
-
}
-
protocols = " imap pop3"
-
service auth {
-
unix_listener /var/spool/postfix/private/auth {
-
group = postfix
-
mode = 0666
-
user = postfix
-
}
-
unix_listener auth-userdb {
-
group = vmail
-
mode = 0600
-
user = vmail
-
}
-
}
-
service pop3-login {
-
inet_listener pop3 {
-
port = 110
-
}
-
inet_listener pop3s {
-
port = 995
-
ssl = yes
-
}
-
}
-
ssl_cert =
-
ssl_key =
-
userdb {
-
driver = passwd
-
}
-
userdb {
-
args = /etc/dovecot/dovecot-ldap.conf.ext
-
driver = ldap
-
}
dovecot-ldap.conf.ext需要修改的如下:
-
hosts = 192.168.1.100:389
-
dn = cn=vmail,cn=Users,dc=example,dc=com
-
dnpass = "1234567"
-
tls = no
-
debug_level = 10
-
auth_bind = yes
-
auth_bind_userdn = cn=%u,cn=Users,dc=example,dc=com
-
ldap_version = 3
-
base = cn=Users,dc=example,dc=com
-
scope = subtree
-
user_attrs = sAMAccountName=home=/data/vmail/%u/Maildir
-
user_filter = (&(objectClass=*)(cn=%u))
-
pass_attrs=uid=user, userPassword=password
-
pass_filter = (&(objectClass=*)(cn=%u))
配置前证书的行请注释掉或者自己配置证书~
特别是配置dovecot的时候,配置文件很多,务必注意了~
如有疑问,请联系QQ46212635,一起探讨!
阅读(4516) | 评论(0) | 转发(0) |