2014-12-28 20:30:29
来 源
中存储网
邮件服务器
ubuntu postfix + dovecot 简易邮件服务需求:建立EMail服务器,提供SMTP和POP3服务,客户用foxmail或者outlook收发信件。前提:域名(mail.example.com)、固定IP、DNS上设置好A、MX、PTR记录使

ubuntu postfix + dovecot 简易邮件服务

需求:
建立EMail服务器,提供SMTP和POP3服务,客户用foxmail或者outlook收发信件。

前提:
域名(mail.example.com)、固定IP、DNS上设置好A、MX、PTR记录

使用软件:
Ubuntu 8.04 Server, Postfix, Dovecot

-------------------------

步骤:
1、装好Ubuntu 8.04,update
注意:如果DNS上PTR记录正确的话,安装过程中系统会自动发现你的主机名和域名。

2、安装postfix

sudo apt-get install postfix

安装完成后,系统会自动提示进行一些基本信息设置。默认即可。

3、初始配置postfix

sudo dpkg-reconfigure postfix

默认即可,反正事后可以在main.cf里改

4、配置main.cf
main.cf文件在/etc/postfix下
在mydestination后加上example.com,成为这个样子:

mydestination = example.com, mail.example.com, localhost.example.com, localhost

这是因为默认情况postfix只接收发到@mail.example.com的邮件,而不接收@example.com的邮件。

5、更改mailbox类型

sudo postconf -e 'home_mailbox = Maildir/'

注:postconf -e和在mail.cf自己写是一回事,-e for edit
这个步骤其实为可选操作。mailbox类型可以是mbox或者是maildir,互有优缺点。但如果将来还打算扩展webmail这类应用,最好选为 Maildir,这样兼容性更好一些。对于dovecot pop3而言,倒是无所谓了。具体mbox和maildir有什么区别,去参考《postfix权威指南》

6、安装dovecot

sudo apt-get install dovecot-pop3d

系统会自动带上dovecot-common,后面配置sasl认证的时候就不用再装了

7、编辑dovecot.conf
主要有两个地方:

mail_location = maildir:~/Maildir

#我们前面设置了mailbox类型为maildir,这是对应的设置。

disable_plaintext_auth = no

#默认情况下,dovecot是不允许plaintext类型的认证的,打开

------------------
重启postfix和dovecot。至此,postfix可以收信,并且foxmail可以pop3取信。测试。
到现在foxmail还不能连接到postfix发信,原因是postfix不进行open relay,OR可不能打开,太危险了。
两种解决方案:
a、在mail.cf里的mynetworks字段加上foxmail所在的网段。默认情况下mynetworks字段只有127.0.0.0/8,所以 你 telnet mail.example.com 25 后,是可以发信的。如果你确定foxmail所在的网段,加上即可。
b、很多情况下发信客户ip是不能确定的,所以打开sasl认证。
接下来配置sasl认证
------------------

8、编辑dovecot.conf
在mechanisms字段加上login,成为这个样子:

mechanisms = plain login

编辑socket listen字段,成为这个样子:

socket listen {
client {
path = /var/spool/postfix/private/auth-client
mode = 0660
user = postfix
group = postfix
}
}

9、给postfix加上如下配置

sudo postconf -e 'smtpd_sasl_type = dovecot'
sudo postconf -e 'smtpd_sasl_path = private/auth-client'
sudo postconf -e 'smtpd_sasl_local_domain ='
sudo postconf -e 'smtpd_sasl_security_options = noanonymous'
sudo postconf -e 'broken_sasl_auth_clients = yes'
sudo postconf -e 'smtpd_sasl_auth_enable = yes'
sudo postconf -e 'smtpd_recipient_restrictions = permit_sasl_authenticated,permit_mynetworks,reject_unauth_destination'
sudo postconf -e 'inet_interfaces = all'

10、重起postfix和dovecot。不出意外的话,已经可以通过foxmail正常收发邮件了

声明: 此文观点不代表本站立场;转载须要保留原文链接;版权疑问请联系我们。