搭建套装: Postfix + Dovecot + Dovecot-SASL
为什么特意要写Dovecot-SASL,因为还有个Cyrus-SASL啊,配置是完全不同的,被坑了无数次啊啊啊。下面正式开始吧。

1. 首先安装Postfix, 把系统默认的sendmail换掉.

yum -y install postfix
yum remove sendmail

2. 配置Postfix.

修改main.cf:

vim /etc/postfix/main.cf

在最后写入配置:

myhostname = $mydomain
mydomain = neathh.com
myorigin = $mydomain
mynetworks = 127.0.0.0/8 [::ffff:127.0.0.0]/104 [::1]/128, 192.168.1.0/24
inet_interfaces = all
mydestination = $myhostname, localhost.$mydomain, localhost, $mydomain
relay_domains = $mydestination
home_mailbox = Maildir/
smtpd_banner = $myhostname ESMTP unknow
smtpd_sasl_auth_enable = yes
smtpd_sasl_type = dovecot
broken_sasl_auth_clients = yes
smtpd_sasl_security_options = noanonymous
smtpd_sasl_authenticated_header = yes
smtpd_sasl_local_domain = $myhostname
smtpd_recipient_restrictions = permit_sasl_authenticated,permit_mynetworks,reject_unauth_destination
smtpd_sasl_path = private/auth

配置master.cf

vim /etc/postfix/master.cf

去掉下面行前面的#号并修改为不使用chroot运行:

smtp      inet  n       -       n       -       -       smtpd

3. Dovecot配置.

修改dovecot.conf:

vim /etc/dovecot/dovecot.conf

写入配置:

disable_plaintext_auth = no
ssl=yes
mail_location = maildir:~/Maildir
pop3_uidl_format = %08Xu%08Xv

auth default {
  mechanisms = plain login
  passdb pam {
  }
  userdb passwd {
  }
  user = root
  socket listen {
    client {
  path = /var/spool/postfix/private/auth
  mode = 0660
  user = postfix
  group = postfix
    }
  }
}

修改10-auth.conf:

vim /etc/dovecot/conf.d/10-auth.conf

将auth_mechanisms选项改成:

auth_mechanisms = plain login

4. 别名设置.

vim /etc/aliases

添加:

root:iam

这样的话发给root的邮件就会送到iam的邮箱账号里。

全部配置完成。
最后重启相关服务就可以了:

service saslauthd restart
service dovecot restart
service postfix restart

5. 测试方法.

测试POP:

shell $> telnet localhost 110
Trying ::1...
Trying 127.0.0.1...
Connected to localhost.
Escape character is '^]'.
+OK Dovecot ready.
**user iam**
+OK
**pass password**
+OK Logged in.
**quit**

SMTP测试:

shell $> telnet localhost 25
Trying ::1...
Trying 127.0.0.1...
Connected to localhost.
Escape character is '^]'.
220 neathh.com ESMTP Postfix (Ubuntu)
**ehlo neathh.com**
250-neathh.com
250-PIPELINING
250-SIZE 10240000
250-VRFY
250-ETRN
250-STARTTLS
250-AUTH PLAIN LOGIN
250-AUTH=PLAIN LOGIN
250-ENHANCEDSTATUSCODES
250-8BITMIME
250 DSN
**quit**

6. 添加新的邮件帐号.
只需要:

shell $>adduser username
passwd username

即可。

参考:

  1. http://www.turbomail.org/turbopost/open-source/show18.html
  2. http://blog.csdn.net/akazhuk/article/details/48315245
  3. https://www.centos.bz/2011/06/centos-install-setup-postfix/#四、测试Postfix SMTP连接
  4. https://www.fancycoding.com/centos7-mail-server-with-dovecot-postfix-ssl/
  5. http://7938217.blog.51cto.com/7928217/1693252
  6. http://www.linuxmail.info/postfix-smtp-auth-dovecot-sasl/
  7. http://www.iredmail.org/docs/allow.insecure.pop3.imap.smtp.connections.html

标签: none

添加新评论