freebsd9.2配置postfix的smtp认证步骤(图解)


    1:卸载sendmail
    cd /usr/ports/mail/sendmail
    make deinstall
    make clean
    2:安装postfix
    cd /usr/ports/mail/postfix
    make config #开启pcre,SASL2,BDB etc..
    make install clean
    
    安装时候会同时安装cyrus-sasl2库,选择配置时候选上BDB等..
    
    
    安装时还会提示是否替换系统默认的mail程序,此处替换,因为已经卸载sendmail
    Would you like to activate Postfix in /etc/mail/mailer.conf [n]? Y
    3:如果没有提示安装cyrus-sasl2库,则需要自己手动安装,配置同上图
    cd /usr/ports/security/cyrus-sasl2
    make install clean
    4.安装cyrus-sasl2-saslauthd程序,选择配置时候选上BDB
    cd /usr/ports/security/cyrus-sasl2-saslauthd
    make install clean
    
    添加一个系统用户 test,测试认证是否正常
    testsaslauthd -u test -p pasword 命令测试时,失败提示: 0:NO “authentication failed” 成功则提示0: OK “Success.”
    安装完成后加入启动项
    ee /etc/rc.conf
    加入
    saslauthd_enable=”YES”
    postfix_enable=”YES”
    5.编辑/usr/local/etc/postfix/main.cf 最下面加入
    #本机邮件服务器域名,在域名里做一下mx解析,指向本机的公网ip,避免被识别为垃圾
    myorigin = mail3.me.com
    #开启smtp
    smtpd_sasl_auth_enable = yes
    broken_sasl_auth_clients = yes
    #白名单ip,可以不用验证密码
    mynetworks = 168.100.189.0/28, 127.0.0.0/8
    smtpd_recipient_restrictions = permit_mynetworks permit_inet_interfaces permit_sasl_authenticated permit_mx_backup reject_unauth_destination
    smtpd_client_restrictions = permit_sasl_authenticated
    smtpd_sasl_local_domain = $myhostname
    6.打开目录 /usr/local/lib/sasl2/里面有个Sendmail.conf,重要!
    cp Sendmail.conf smtpd.conf
    生成/etc/aliases.db,运行 重要!
    newaliases