您的位置:首页 > 运维架构 > Linux

centos7配置postfix dovecot cyrus-sasl foxmail

2015-12-28 13:25 519 查看
第一步:(Windows本地安装foxmail测试两账号成功互收发)
yum install postfix dovecot cyrus-sasl cyrus-sasl-plain cyrus-sasl-md5

记录类型 主机记录 解析线路 记录值 MX优先级 TTL
TXT @ 默认 v=spf1 ip4:111.11.11.11 -all -- 10分钟
MX @ 默认 mail.wc365.com. 10 10分钟
A smtp 默认 111.11.11.11 -- 10分钟
A mail 默认 111.11.11.11 -- 10分钟
A pop3 默认 111.11.11.11 -- 10分钟

# vi /etc/postfix/main.cf
myhostname = mail.wc365.com
mydomain = wc365.com
myorigin = $mydomain
inet_interfaces = all
inet_protocols = ipv4
mydestination = $myhostname, localhost.$mydomain, localhost, $mydomain,
mail.$mydomain, www.$mydomain, ftp.$mydomain
mynetworks = 0.0.0.0/0
home_mailbox = Maildir/(测试之后发现是与foxmail设置验证有关,必须要)
relay_domains = $mydestination
broken_sasl_auth_clients = yes
smtpd_client_restrictions = permit_sasl_authenticated
smtpd_recipient_restrictions = permit_mynetworks, permit_sasl_authenticated, reject_unauth_destination
smtpd_sasl_auth_enable = yes
smtpd_sasl_local_domain = $mydomain
smtpd_sasl_security_options = noanonymous
message_size_limit = 5242880
# systemctl start postfix.service(检查25号端口)

# vi /etc/dovecot/dovecot.conf
protocols = imap pop3 lmtp
listen = *
# vi 10-auth.conf(没测试,暂时没用到)
disable_plaintext_auth = no
# vi 10-mail.conf(测试之后发现是与foxmail设置验证有关,必须要)
mail_location = maildir:~/Maildir
#mail_location = maildir:/var/mailbox/%d/%n/Maildir
mail_privileged_group = mail
# vi 10-ssl.conf(没测试,暂时没用到)
ssl = no
# systemctl start dovecot.service(检查110,143号端口)

# vi /etc/sysconfig/saslauthd
SOCKETDIR=/var/run/saslauthd
MECH=shadow

# cat /etc/sasl2/smtpd.conf
pwcheck_method: saslauthd
mech_list: plain login
# systemctl start saslauthd.service

增加用户:
userdel test1(删除用户)
groupdel test1(删除用户组)

useradd test2
echo 'test2' |passwd --stdin test2
useradd test3
echo 'test3' |passwd --stdin test3
vi /etc/passwd
test2:x:1001:2001::/home/test2:/sbin/nologin(不能登录系统)
test3:x:1002:2002::/home/test3:/sbin/nologin

测试1:
# telnet mail.wc365.com 25
Trying 192.168.1.2...
Connected to mail.wc365.com (192.168.1.2).
Escape character is '^]'.
220 mail.yjw.com ESMTP Postfix
EHLO 163.com(只需要输入该行即可,一下都是现实信息)
250-mail.wc365.com
250-PIPELINING
250-SIZE 10240000
250-VRFY
250-ETRN
250-AUTH LOGIN PLAIN
250-AUTH=LOGIN PLAIN
250-ENHANCEDSTATUSCODES
250-8BITMIME
250 DSN
quit(输入退出命令)
221 2.0.0 Bye
Connection closed by foreign host.

测试2:

echo "this is a test mail" | mail -s mailname 123456789@qq.com(查看QQ邮箱是否有新邮件)

测试3:
Windows安装的foxmail客户端
新建--》手动设置--》配置如下--》创建--》确定(应用)--》邮件成功互收发即可
接受服务器类型:POP3
邮件账号:test2@wc365.com
密码: 123456
POP服务器:mail.wc365.com 110
SMTP服务器:mail.wc365.com 25

检查3:
默认的MTA是sendmail。所以我们需要键入以下命令更新MTA为Postfix
/usr/sbin/alternatives --set mta /usr/sbin/sendmail.postfix
再次检查看MTA是不是改为Postfix了
alternatives --display mta

报错1:postfix/sendmail[13310]: fatal: parameter inet_interfaces: no local interface found for ::1
解决1:
vi /etc/postfix/main.cf
#inet_protocols = all(注释掉该行)
#wc add1
inet_protocols = ipv4
systemctl start postfix(检查端口号查看是否起来)

报错2:ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/tmp/mysql.sock' (111)
解决2:ln -s /var/lib/mysql/mysql.sock /tmp/mysql.sock

报错3:dovecot: pop3-login: Aborted login (auth failed, 1 attempts in 4 secs
解决3:一般都是权限问题
ll /var/mail或者ll /home

报错4:error: mailbox_size_limit is smaller than message_size_limit
解决4:message_size_limit = 5120000(数值改小即可)

报错5:useradd: group wc exists - if you want to add this user to that group, use -g.
解决5:这是因为只删除了用户,用户组没有删除的原因userdel test1(删除用户)groupdel test1(删除用户组)

报错6:

第二步: http://www.centoscn.com/CentosServer/lighttpd/2013/1010/1775.html
第三步:(加入mysql实现虚拟用户收发邮件)
参考: http://www.haiyun.me/archives/953.html
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  postfix dovecot cyrus-sasl