ubuntu14.04下安装postfix+cyrus-sasl经验

1.sudo apt-get install postfix;

2.sudo apt-get insatll sasl2-bin;

3.配置postfix/main.cf:

在配置mail的域名的时候,一定不能使用example.com这种默认的,不然163会直接拒收。

smtpd_relay_restrictions = permit_mynetworks permit_sasl_authenticated defer_unauth_destination reject_unauth_destination
myhostname = mail.test.com
mydomain=test.com
myorigin = $mydomain
mydestination = $myhostname.localhost.$mydomain,localhost,$mydomain
relayhost =
mynetworks = 127.0.0.0/8 192.168.0.0/24
mynetworks_style = class
relay_domains=$mydestination
home_mailbox = Maildir/
mailbox_size_limit = 0
recipient_delimiter = +
inet_interfaces = all
inet_protocols = ipv4


smtpd_sasl_auth_enable = yes
smtpd_sasl_local_domain = $myhostname
smtpd_recipient_restrictions = permit_mynetworks,permit_sasl_authenticated,reject_unauth_destination
smtpd_client_restrictions = permit_sasl_authenticated
broken_sasl_auth_clients = yes
smtpd_sasl_path = smtpd
smtpd_sasl_security_options = noanonymous
smtpd_sasl_authenticated_header = yes
message_size_limit = 15728640

4.在/etc/postfix/sasl/目录下创建文件smtpd.conf,内容为:

pwcheck_method: auxprop
auxprop_plugin: sasldb
mech_list: PLAIN LOGIN CRAM-MD5 DIGEST-MD5 NTLM

5.使用saslpasswd2创建用户:

saslpasswd2 -c -u test.com test

sudo cp -a /etc/sasldb2 /var/spool/postfix/etc/ //这里很关键,在ubuntu下postfix所能浏览的目录有限制,必须把数据库文件复制到postfix的运行目录下,不然在用户验证的时候会出错。

6.将postfix添加到sasl组:

gpasswd -a postfix sasl

修改sasldb权限

chmod 640 /var/spool/postfix/etc/sasldb2

列举sasldb2中的用户

sasldblistusers2 -f /var/spool/postfix/etc/sasldb2

7.telnet验证:

telnet 127.0.0.1 25

auth login

然后输入邮箱账户的base64码,在输入密码的base64码。


在编译postfix的时候要注意libdb.so的版本,如果在/usr/lib下没有libdb.so这个库,最好用ln创建一个连接。如果编译环境中的libdb和运行环境中的libdb版本不相同的话,在运行的时候会出错,程序退出!


你可能感兴趣的:(linux,os,postfix,cyrus-sasl)