freebsd安装及安全使用SSMTP
第一步:ee /ec/rc.conf中加入
sendmail_enable=”NO”
sendmail_submit_enable=”NO”
sendmail_outbound_enable=”NO”
sendmail_msp_queue_enable=”NO”
killall sendmail
第二步:安装ssmtp:
pkg install ssmtp
ee /etc/mail/mailer.conf
sendmail /usr/libexec/sendmail/sendmail
send-mail /usr/libexec/sendmail/sendmail
mailq /usr/libexec/sendmail/sendmail
newaliases /usr/libexec/sendmail/sendmail
hoststat /usr/libexec/sendmail/sendmail
purgestat /usr/libexec/sendmail/sendmail
to
sendmail /usr/local/sbin/ssmtp
send-mail /usr/local/sbin/ssmtp
mailq /usr/libexec/sendmail/sendmail
newaliases /usr/libexec/sendmail/sendmail
hoststat /usr/libexec/sendmail/sendmail
purgestat /usr/libexec/sendmail/sendmail
第三步:创建ssmtp用户
pw useradd ssmtp -g nogroup -h – -s /sbin/nologin -d /nonexistent -c “sSMTP pseudo-user”
第四步:
cd /usr/local/etc/ssmtp
chown ssmtp:wheel .
chmod 4750 .
第五步:
cp ssmtp.conf.sample ssmtp.conf
chown ssmtp:wheel . ssmtp.conf
chmod 640 ssmtp.conf
第六步:编辑ssmtp.conf文件
mailhub=smtp.exmail.qq.com:465
UseTLS=YES
AuthUser=from@mydomain.com
AuthPass=123456
FromLineOverride=YES
Hostname=serverkvm
RewriteDomain=exmail.qq.com
Root=postmaster
cp revaliases.sample revaliases
root:from@mydomain.com:smtp.exmail.qq.com:465
from:from@mydomain.com:smtp.exmail.qq.com:465
chown ssmtp:nogroup /usr/local/sbin/ssmtp
chmod 4555 /usr/local/sbin/ssmtp
测试:echo “test” | mail -v -s “test mail” your_mail@domain.com
评论