正在加载...

CentOS 快速搭建邮件服务

[ 2013/03/25 15:35 | by selboo ]

cyrus-sasl    账户认证(本地)
postfix       发送邮件
dovecot     接受邮件

一、系统配置

    所有账户邮件存放在 系统 /data/%U 目录下

    修改用户模板,新添加用户自动创建 Mail 目录用于存放邮件文件

    域:mxt.selboo.com.cn MX记录 mail.mxt.selboo.com.cn

用户模板下建立用户邮箱目录
This is The Code
[root@selboo ~]# mkdir /etc/skel/Mail
[root@selboo ~]# chmod 700 /etc/skel/Mail
Parsed in 0.000 seconds at N/A

创建 "m1" 邮件账号
This is The Code
[root@selboo ~]# useradd -s /sbin/nologin -d /data/m1 m1
Parsed in 0.000 seconds at N/A

修改 "m1" 密码 为 '12345567'
This is The Code
[root@selboo ~]# echo '12345567' | passwd --stdin m1
Changing password for user m1.
passwd: all authentication tokens updated successfully.
Parsed in 0.000 seconds at N/A

安装软件
This is The Code
[root@selboo ~]# yum install postfix cyrus-sasl* dovecot
Parsed in 0.000 seconds at N/A

二、cyrus-sasl 配置

1、修改 /etc/sysconfig/saslauthd 文件 使用本地认证

This is The Code
cat /etc/sysconfig/saslauthd | grep -v '^#'
SOCKETDIR=/var/run/saslauthd
MECH=shadow
Parsed in 0.000 seconds at N/A


2、修改 smtpd.conf
This is The Code
[root@selboo ~]#  cat /etc/sasl2/smtpd.conf
pwcheck_method: saslauthd
mech_list: plain login
Parsed in 0.000 seconds at N/A


3、验证 sasl 是否正常
This is The Code
[root@selboo ~]# testsaslauthd -u m1 -p 12345567
0: OK "Success."
Parsed in 0.000 seconds at N/A


三、Postfix配置

main.cf 配置文件
This is The Code
cat /etc/postfix/main.cf | grep -v '^#'
queue_directory = /var/spool/postfix
command_directory = /usr/sbin
daemon_directory = /usr/libexec/postfix
data_directory = /var/lib/postfix
mail_owner = postfix
myhostname = mail.mxt.selboo.com.cn
mydomain = mxt.selboo.com.cn
myorigin = $myhostname
inet_interfaces = all
mydestination = $myhostname, localhost.$mydomain, localhost, $mydomain, mail.$mydomain, www.$mydomain, ftp.$mydomain
unknown_local_recipient_reject_code = 550
mynetworks_style = subnet
mynetworks  = 127.0.0.1
relay_domains = $mydestination
alias_maps = hash:/etc/aliases
alias_database = hash:/etc/aliases

home_mailbox = Mail/
 
debug_peer_level = 2
sendmail_path = /usr/sbin/sendmail.postfix
newaliases_path = /usr/bin/newaliases.postfix
mailq_path = /usr/bin/mailq.postfix
setgid_group = postdrop
html_directory = no
manpage_directory = /usr/share/man
sample_directory = /usr/share/doc/postfix-2.6.6/samples
readme_directory = /usr/share/doc/postfix-2.6.6/README_FILES

# sasl 认证
smtpd_sasl_auth_enable = yes
smtpd_sasl_security_options = noanonymous
broken_sasl_auth_clients = yes
smtpd_recipient_restrictions = permit_sasl_authenticated,reject_unauth_destination,permit_mynetworks
smtpd_client_restrictions = permit_sasl_authenticated
Parsed in 0.000 seconds at N/A

四、dovecot 配置

1、修改 /etc/dovecot/dovecot.conf 文件

This is The Code
[root@selboo ~]# cat /etc/dovecot/dovecot.conf | grep -E "protocols|listen ="
protocols = pop3
listen = *
Parsed in 0.000 seconds at N/A
只启用 POP3 和 只监听 IPV4 地址

2、关闭 POP3S 协议
This is The Code
[root@selboo ~]# cat /etc/dovecot/conf.d/10-ssl.conf | grep "ssl ="
ssl = no
Parsed in 0.000 seconds at N/A

3、指定邮件目录
This is The Code
[root@selboo ~]# cat 10-mail.conf | grep "mail_location = maildir"
mail_location = maildir:~/Mail
Parsed in 0.000 seconds at N/A

4、修改auto文件
This is The Code
[root@selboo ~]# cat 10-auth.conf | grep disable_plaintext_auth
disable_plaintext_auth = no
Parsed in 0.000 seconds at N/A
否在在收信时会出错 错误一

五、错误记录
1、错误一
/var/log/maillog 文件
dovecot: pop3-login: Disconnected (tried to use disabled plaintext auth)

2、错误二
/var/log/maillog 文件
Initialization failed: mail_location not set and autodetection failed: Mail storage autodetection fa

解决二
/etc/dovecot/conf.d/10-mail.conf
mail_location = maildir:~/Mail

参考文章:
http://book.selboo.com.cn/mail/postfix_smtp.html
http://book.selboo.com.cn/mail/dovecot_pop3.html
postfix 错误汇总
最后编辑: selboo 编辑于2013/03/26 10:14
,
发表评论
表情
打开HTML
打开UBB
打开表情
隐藏
记住我
昵称   密码   游客无需密码
网址   电邮   [注册]