10 March 2013

因为Sendmail有邮件发送但是发不出时会导致系统启动过程等待超时,浪费时间,因此用sSMTP配合Gmail替换掉Sendmail服务 1,取消Sendmail开机启动,并结束Sendmail进程

sendmail_enable="NO"

sendmail_submit_enable="NO"

sendmail_outbound_enable="NO"

sendmail_msp_queue_enable="NO"


将这段代码加到/etc/rc.conf中去,下次启动就不会启动Sendmail了结束Sendmail进程

killall  sendmail


并且按照http://www.freebsd.org/doc/handbook/mail-changingmta.html#MAIL-DISABLE-SENDMAIL,修改/etc/mail/mailer.conf,修改以下两行:

sendmail /usr/local/sbin/ssmtp

send-mail /usr/local/sbin/ssmtp

2,从Ports安装sSMTP

# cd /usr/ports/mail/ssmtp

# make install replace clean


3,配置sSMTP 修改/usr/local/etc/ssmtp/ssmtp.conf(没有手动增加就是了)

root=xxx@gmail.com

mailhub=smtp.gmail.com:587

rewriteDomain=

hostname=smtp.gmail.com:587

FromLineOverride=YES

UseTLS=YES

AuthUser=xxx@gmail.com

AuthPass=yy

UseSTARTTLS=YES


4,配置完成发送邮件测试

echo "test" | mail -v -s "test mail" your_mail@domain.com

echo "test" | mail -s "test mail" root


5,gmail安全设置

如果第四步出现认证错误,可能的原因是gmail检测到异常ip登陆,这时候需要登陆gmail账号,可能需要填写验证码,或者消除验证码异常的设备登陆,具体情况参见:https://support.google.com/mail/answer/14257?p=client_login&rd=1