更改邮件配置 以163邮箱为例
#vim /etc/mail.rc
在文件末尾添加
set bsdcompat
set from=******@163.com
set smtp=smtps://smtp.163.com:465
set smtp-auth-user=*****@163.com
set smtp-auth-password=****** #该密码为163邮箱设置里的客户端授权密码,不是邮箱的登录密码
set smtp-auth=login
set ssl-verify=ignore
set nss-config-dir=/root/.certs #数字证书文件夹
请求数字证书
# mkdir -p /root/.certs/ ####创建目录,用来存放证书
# echo -n | openssl s_client -connect smtp.163.com:465 | sed -ne '/-BEGIN CERTIFICATE-/,/-END CERTIFICATE-/p' > ~/.certs/163.crt ####向163请求证书
# certutil -A -n "GeoTrust SSL CA" -t "C,," -d ~/.certs -i ~/.certs/163.crt ####添加一个SSL证书到证书数据库中
# certutil -A -n "GeoTrust Global CA" -t "C,," -d ~/.certs -i ~/.certs/163.crt ####添加一个Global 证书到证书数据库中
# certutil -L -d /root/.certs ####列出目录下证书
测试
# echo "test" | mail -s "zabbix" *****@163.com
# smtp-server: 550 User has no permission
"/root/dead.letter" 11/293. . . message not sent.
这个问题为用户不被信任
解决步骤
# cd /root/.certs/
# ll
# certutil -A -n "GeoTrust SSL CA - G3" -t "Pu,Pu,Pu" -d ./ -i 163.crt
Notice: Trust flag u is set automatically if the private key is present. #这个提示表示设置成功
常见的错误提示
1、The server rejected the message: 554 DT:SPM smtp2 Cannot send message 451 MI:SFQ 0,smtp9,DcCowLD735x2fG1MgWLhAA--.11609S2 1282243
邮件服务器拒绝发送邮件,判断为发送垃圾邮件。建议您检查邮件内容,是否包含一些比较敏感的内容。
2、Cannot send message data: 550 5.4.5 Daily sending quota exceeded. q31sm4299413ybk.1
不能发送邮件,每日发送额度用完。建议您控制此邮箱每天的发送量,今天发送量已经用完,需要明天才能继续发送。
3、Recipient rejected: xxx@163.com: 553 5.7.1 < xx@xx.com >: Sender address rejected: not owned by user xx@xx.com
发送邮箱地址被拒绝。建议您换个邮箱发送。
4、Recipient rejected: xxx@163.com: 550 Your mailbox is full?
您的邮箱空间已满不能再发送邮件。建议您整理邮箱中的邮件。
5、Cannot send message: 451 sorry, server closed?
不能发送,服务器已经关闭。建议您稍候再尝试邮件发送操作 。
6、Recipient rejected: xxx@163.com: 500 Error: bad syntax
收件人地址格式不正确。请核实收件人地址是否正确。
7、421 Service not available, closing transmission channel (This may be a reply to any command if the service knows it must shut down)
服务暂时不可用!建议您稍候再尝试发送。
8、450 Requested mail action not taken: mailbox unavailable (E.g., mailbox busy)
邮件发送请求没有发生:邮箱不可用(例如,邮箱忙)!建议您稍候再尝试!
9、451 Requested action aborted: local error in processing
请求的邮件操作被中止:本地进程错误。建议您重新启动邮件营销助手来尝试发送
10、550 Requested action not taken: mailbox unavailable (E.g., mailbox not found, no access)?
请求的操作未被执行:邮箱不可用(例如,邮箱未找到,不能访问)。建议您稍候再尝试。
11、552 Requested mail action aborted: exceeded storage allocation
请求的邮件操作中止:超出存储分配。建议您整理邮箱中的邮件。
·12、553 Requested action not taken: mailbox name not allowed (E.g., mailbox syntax incorrect)
请求的操作未被执行:不允许的邮箱名称(例如,邮箱的语法不正确的);
13、550 5.3.4 Requested action not taken; This account is currently blocked from sending messages. If you don't think you've violated the Windows Live Terms of Use, please contact customer support
请求不采取行动,这是目前从帐户发送的邮件被阻止。如果您不认为您已经违反了Windows Live的使用条款,请联系其客户支持。