码迷,mamicode.com
首页 > 其他好文 > 详细

zabbix使用系统自带mailx(mail)SMTP发送邮件

时间:2017-06-16 23:04:38      阅读:1034      评论:0      收藏:0      [点我收藏+]

标签:mailx(mail)smtp发送邮件

0x01,环境介绍:

我们用的是微软的邮箱打算用SMTP方式发送邮件。先登录账户看官方给出SMTP信息。

技术分享


0x02,系统mailx(mail)设置。

通过命令可以看到,mail实际上是mailx的快捷方式。然后在/etc/mail.rc里加入账号等信息。

技术分享

SMTP加密方式是:STARTTLS

set from=Zabbix使用的发送邮件地址
set smtp=smtp.office365.com
set smtp-auth-user=Zabbix使用的发送邮件地址
set smtp-auth-password=密码
set smtp-auth=login
set smtp-use-starttls
set ssl-verify=ignore
set nss-config-dir=/etc/pki/nssdb/


0x03,创建存放证书的目录

# mkdir -p /etc/pki/nssdb/


0x04,测试mail命令

echo "Zabbix test" | mailx -v -s "test" wutou@wutou.com

Zabbix test 要发送的邮件内容,多行内容要写""里。

test 发送邮件的标题。

wutou@wutou.com 是对方接收邮件的账号。


0x05,测试执行结果,显示如下说明成功。

Resolving host smtp.office365.com . . . done.
Connecting to 40.97.113.2:smtp . . . connected.
220 DM5PR06CA0069.outlook.office365.com Microsoft ESMTP MAIL Service ready at Fri, 16
 Jun 2017 03:16:13 +0000
>>> EHLO iconnappdev.us.wutou.net
250-DM5PR06CA0069.outlook.office365.com Hello [204.246.137.148]
250-SIZE 157286400
250-PIPELINING
250-DSN
250-ENHANCEDSTATUSCODES
250-STARTTLS
250-8BITMIME
250-BINARYMIME
250 CHUNKING
>>> STARTTLS
220 2.0.0 SMTP server ready
Error in certificate: Peer‘s certificate issuer is not recognized.
Comparing DNS name: "*.clo.footprintdns.com"
Comparing DNS name: "*.hotmail.com"
Comparing DNS name: "*.internal.outlook.com"
Comparing DNS name: "*.live.com"
Comparing DNS name: "*.office.com"
Comparing DNS name: "*.office365.com"
SSL parameters: cipher=AES-256, keysize=256, secretkeysize=256,
issuer=CN=DigiCert Cloud Services CA-1,O=DigiCert Inc,C=US
subject=CN=outlook.com,O=Microsoft Corporation,L=Redmond,ST=Washington,C=US
>>> EHLO appdev.us.wutou..net
250-DM5PR06CA0069.outlook.office365.com Hello [204.246.137.148]
250-SIZE 157286400
250-PIPELINING
250-DSN
250-ENHANCEDSTATUSCODES
250-AUTH LOGIN XOAUTH2
250-8BITMIME
250-BINARYMIME
250 CHUNKING
>>> AUTH LOGIN
334 VXNlcm5hbWU6
>>> emFiYml4QGFyaWl4LmNvbQ==
334 UGFzc3dvcmQ6
>>> WmFyaWl4MTE=
235 2.7.0 Authentication successful target host BN6PR11MB0017.namprd11.prod.outlook.com
>>> MAIL FROM:<wutou@wutou.net>
250 2.1.0 Sender OK
>>> RCPT TO:<wutou@wutou.net>
250 2.1.5 Recipient OK
>>> DATA
354 Start mail input; end with <CRLF>.<CRLF>
>>> .
250 2.6.0 <59434d32.Lx4d3eMhjzYuCHGO%wutou@wutou.net> [InternalId=4849018077783, Hostn
   ame=BN6PR11MB0017.namprd11.prod.outlook.com] 2808 bytes in 0.560, 4.895 KB/sec Queued 
   mail for delivery
>>> QUIT
221 2.0.0 Service closing transmission channel


0x06,邮件错误,邮件没有发送成功说明,是认证方式没有设置对。

[root@appdev zabbix-303]# echo hello | mailx -v -s "test" wutou@wutou.net
Resolving host smtp.office365.com . . . done.
Connecting to 40.97.134.210:smtp . . . connected.
220 MWHPR15CA0065.outlook.office365.com Microsoft ESMTP MAIL Service ready at Fri, 16 
   Jun 2017 03:14:01 +0000

250-MWHPR15CA0065.outlook.office365.com Hello [204.246.137.148]
250-SIZE 157286400
250-PIPELINING
250-DSN
250-ENHANCEDSTATUSCODES
250-STARTTLS
250-8BITMIME
250-BINARYMIME
250 CHUNKING
>>> STARTTLS
220 2.0.0 SMTP server ready
Missing "nss-config-dir" variable.
"/root/dead.letter" 11/296
. . . message not sent.






参考文章:

http://www.mamicode.com/info-detail-1430328.html

http://freman.blog.51cto.com/1309295/1216126/







本文出自 “悟透的杂货铺” 博客,请务必保留此出处http://wutou.blog.51cto.com/615096/1939117

zabbix使用系统自带mailx(mail)SMTP发送邮件

标签:mailx(mail)smtp发送邮件

原文地址:http://wutou.blog.51cto.com/615096/1939117

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!