{"id":335,"date":"2019-01-17T16:01:53","date_gmt":"2019-01-17T08:01:53","guid":{"rendered":"https:\/\/blog.espnlol.com\/?p=335"},"modified":"2022-04-20T18:28:52","modified_gmt":"2022-04-20T10:28:52","slug":"linux%e4%b8%8b%e5%88%a9%e7%94%a8mailx%e9%85%8d%e7%bd%ae%e8%85%be%e8%ae%af%e4%bc%81%e4%b8%9a%e9%82%ae%e7%ae%b1smtps-465%e7%ab%af%e5%8f%a3%e5%8f%91%e9%80%81%e9%82%ae%e4%bb%b6","status":"publish","type":"post","link":"https:\/\/blog.espnlol.com\/?p=335","title":{"rendered":"Linux\u4e0b\u5229\u7528mailx\u914d\u7f6e\u817e\u8baf\u4f01\u4e1a\u90ae\u7bb1smtps 465\u7aef\u53e3\u53d1\u9001\u90ae\u4ef6"},"content":{"rendered":"<h2><strong>\u5b89\u88c5\u548c\u914d\u7f6e\u7cfb\u7edf\u7684 mailx<\/strong><\/h2>\n<p>\u8fd9\u91cc\u4ee5\u670d\u52a1\u5668\u9996\u9009\u7684\u00a0CentOS 7\u4e3a\u4f8b\uff08\u597d\u50cf\u9ed8\u8ba4\u90fd\u5df2\u7ecf\u96c6\u6210\u4e86 mailx \u7684\uff0c\u81f3\u4e8e\u8bf4 sendmail\uff0c\u660e\u6708\u611f\u89c9\u6548\u80fd\u5dee\uff0c\u5c31\u4e0d\u505a\u53c2\u8003\u4e86\uff09\u3002<\/p>\n<p>\u8fd0\u884c\u547d\u4ee4\uff1a<\/p>\n<div class=\"dp-highlighter nogutter\">\n<ol class=\"dp-c\" start=\"1\">\n<li class=\"alt\">yum\u00a0-y\u00a0install\u00a0mailx<\/li>\n<\/ol>\n<\/div>\n<p>\u5373\u53ef\u81ea\u52a8\u5b89\u88c5 mialx \u4e86\u3002\u5b89\u88c5\u5b8c\u6210\u540e\uff0c\u7f16\u8f91 \/etc\/mail.rc \u6587\u4ef6\u914d\u7f6e mailx \u4f7f\u7528 \u817e\u8baf\u4f01\u4e1a\u90ae\u7bb1\u4f5c\u4e3a\u53d1\u9001\u90ae\u4ef6\u90ae\u7bb1\u3002<\/p>\n<p>\u5728\u914d\u7f6e\u6587\u4ef6\u6700\u540e\u6dfb\u52a0\u5982\u4e0b\u817e\u8baf\u4f01\u4e1a\u90ae\u7bb1 \u90ae\u7bb1\u914d\u7f6e\u5373\u53ef\uff08\u8bb0\u5f97\u4fdd\u5b58\u66f4\u65b0\u54e6\uff09\uff1a<\/p>\n<pre class=\"lang:default decode:true\">vi\u00a0\/etc\/mail.rc\r\n'''\r\nset\u00a0from=xxxxxx@$domain.com\r\nset\u00a0smtp=smtps:\/\/smtp.exmail.qq.com:465\r\nset\u00a0smtp-auth-user=xxxxxx@$domain.com\r\nset\u00a0smtp-auth-password=\u4f60\u7684\u817e\u8baf\u4f01\u4e1a\u90ae\u7bb1\u5bc6\u7801\r\nset\u00a0smtp-auth=login\r\nset\u00a0ssl-verify=ignore\r\nset\u00a0nss-config-dir=\/etc\/zabbix\/scripts\/.certs<\/pre>\n<p>\u8bb0\u5f97\u8981\u7528\u5230\u817e\u8baf\u4f01\u4e1a\u90ae\u7bb1\u5bc6\u7801\u54e6\uff0c\u53ef\u4ee5\u63d0\u524d\u590d\u5236\u586b\u5230\u6807\u6ce8\u7684\u5bf9\u5e94\u4f4d\u7f6e\u5373\u53ef\uff01<\/p>\n<p>\u56e0\u4e3a\u963f\u91cc\u4e91 ECS \u5c01\u7981\u4e86 25 \u7aef\u53e3\uff0c\u6240\u4ee5\u6211\u4eec\u53ea\u80fd\u4f7f\u7528 TLS \u65b9\u5f0f\uff08TSL \u4e5f\u5c31\u662f\u4f7f\u7528 SSL \u52a0\u5bc6\u7684\u65b9\u5f0f,\u4f7f\u7528 465 \u6216\u8005\u5176\u4ed6\u7aef\u53e3\u6765\u53d1\u9001\u90ae\u4ef6\uff09\u7ed5\u8fc7 25 \u7aef\u53e3\u9700\u6c42\u6765\u53d1\u9001\u90ae\u4ef6\uff0c\u6240\u4ee5\u5fc5\u987b\u5148\u83b7\u5f97\u90ae\u7bb1\u7684\u00a0SSL \u8bc1\u4e66\u5e76\u5b58\u653e\u5230\u672c\u5730\uff0c\u6700\u540e\u4e00\u884c\u7684 nss-config-dir \u5c31\u662f\u5236\u5b9a\u7684\u5b58\u653e QQ \u90ae\u7bb1 SSL \u8bc1\u4e66\u7684\u4f4d\u7f6e\u3002<\/p>\n<p>\u56e0\u4e3a\u9700\u8981 \u817e\u8baf\u4f01\u4e1a\u90ae\u7bb1\u7684 SSL \u8bc1\u4e66\uff0c\u6240\u4ee5\u6211\u4eec\u8fd8\u9700\u8981\u624b\u52a8\u7684\u83b7\u53d6\u817e\u8baf\u4f01\u4e1a\u90ae\u7bb1\u7684\u8bc1\u4e66\u4fdd\u5b58\u5230\u672c\u5730\u6307\u5b9a\u7684\u76ee\u5f55\u91cc\u4ee5\u5907\u8c03\u7528\u548c\u9a8c\u8bc1\uff0c\u5177\u4f53\u547d\u4ee4\u5982\u4e0b\uff1a<\/p>\n<div class=\"dp-highlighter nogutter\">\n<ol class=\"dp-c\" start=\"1\">\n<li class=\"alt\"><span class=\"func\">mkdir<\/span>\u00a0-p \/etc\/zabbix\/scripts\/.certs<\/li>\n<li class=\"\">echo -n | openssl s_client -connect smtp.exmail.qq.com:465 | sed -ne &#8216;\/-BEGIN CERTIFICATE-\/,\/-END CERTIFICATE-\/p&#8217; &gt;\/etc\/zabbix\/scripts\/.certs\/qq.crt<\/li>\n<li class=\"alt\">certutil -A -n &#8220;GeoTrust SSL CA&#8221; -t &#8220;C,,&#8221; -d \/etc\/zabbix\/scripts\/.certs\/ -i \/etc\/zabbix\/scripts\/.certs\/qq.crt<\/li>\n<li class=\"\">certutil -A -n &#8220;GeoTrust Global CA&#8221; -t &#8220;C,,&#8221; -d \/etc\/zabbix\/scripts\/.certs\/ -i \/etc\/zabbix\/scripts\/.certs\/qq.crt<\/li>\n<li class=\"alt\">certutil -L -d \/etc\/zabbix\/scripts\/.certs\/<\/li>\n<\/ol>\n<\/div>\n<p>\u4e3a\u4e86\u9632\u6b62\u51fa\u73b0\u524d\u6587\u6240\u8bf4\u7684\u53d1\u9001\u90ae\u4ef6\u8b66\u544a\u63d0\u793a\uff0c\u8fd8\u9700\u8981\u8fdb\u5165\u90ae\u7bb1 SSL \u8bc1\u4e66\u5b58\u653e\u76ee\u5f55 \/root\/.certs \u91cc\u6267\u884c\u5982\u4e0b\u547d\u4ee4\uff1a<\/p>\n<div class=\"dp-highlighter nogutter\">\n<ol class=\"dp-c\" start=\"1\">\n<li class=\"alt\">cd \/etc\/zabbix\/scripts\/.certs\/ &amp;&amp; certutil\u00a0-A\u00a0-n\u00a0<span class=\"string\">&#8220;GeoTrust\u00a0SSL\u00a0CA\u00a0&#8211;\u00a0G3&#8221;<\/span>\u00a0-t\u00a0<span class=\"string\">&#8220;Pu,Pu,Pu&#8221;<\/span>\u00a0-d\u00a0.\/\u00a0-i\u00a0qq.crt<\/li>\n<\/ol>\n<\/div>\n<p>\u8fd4\u56de\u5982\u4e0b\u63d0\u793a\u5373\u53ef\uff1a<\/p>\n<div class=\"dp-highlighter nogutter\">\n<ol class=\"dp-c\" start=\"1\">\n<li class=\"alt\">**Notice:\u00a0Trust\u00a0flag\u00a0u\u00a0is\u00a0set\u00a0automatically\u00a0<span class=\"keyword\">if<\/span>\u00a0the\u00a0<span class=\"keyword\">private<\/span>\u00a0key\u00a0is\u00a0present.**<\/li>\n<\/ol>\n<\/div>\n<p>\u8fd9\u662f\u4e3a\u4e86\u4fe1\u4efb\u8bc1\u4e66\u7684\u6807\u8bb0\u64cd\u4f5c\u3002<\/p>\n<p>\u81f3\u6b64\uff0c\u5df2\u7ecf\u5b8c\u6210\u4e86 mailx \u7ed3\u5408 \u817e\u8baf\u4f01\u4e1a\u90ae\u7bb1\u90ae\u7bb1\u53d1\u9001\u7cfb\u7edf\u90ae\u4ef6\u7684\u90e8\u7f72\u4e86\uff0c\u901a\u8fc7\u547d\u4ee4\u884c\u53d1\u9001\u6d4b\u8bd5\u90ae\u4ef6\u8bd5\u8bd5\u5427\uff1a<\/p>\n<div class=\"dp-highlighter nogutter\">\n<ol class=\"dp-c\" start=\"1\">\n<li class=\"alt\">mailx\u00a0-s\u00a0<span class=\"string\">&#8220;\u90ae\u7bb1\u6d4b\u8bd5&#8221;<\/span>\u00a0xxxx@$domain.com\u00a0&lt;\u00a0message_file.txt<\/li>\n<\/ol>\n<\/div>\n<p><strong>\u547d\u4ee4\u884c\u89e3\u8bfb\uff1a<\/strong>\u53d1\u9001\u4e3b\u9898\u4e3a\u201c\u90ae\u7bb1\u6d4b\u8bd5\u201d\uff0c\u5185\u5bb9\u4e3a\u5f53\u524d\u76ee\u5f55\u4e0b message_fiel.txt \u6587\u4ef6\u5185\u5bb9\u5230 xxxx@$domain.com \u90ae\u7bb1\u3002<\/p>\n<p>\u6d4b\u8bd5\u90ae\u4ef6\u4e00\u65e6\u6210\u529f\uff0c\u6536\u4ef6\u7bb1\u4f1a\u9a6c\u4e0a\u6536\u5230\u90ae\u4ef6\uff0c\u5982\u679c\u6ca1\u6709\u6536\u5230\uff0c\u5219\u7b49\u4e00\u4f1a\u53ef\u4ee5\u770b\u5230 shell \u754c\u9762\u7684\u9519\u8bef\u63d0\u793a\uff1b\u53cd\u6b63\u660e\u6708\u7167\u7740\u4e0a\u8ff0\u8bbe\u7f6e\u540e\u662f\u6210\u529f\u6536\u5230\u90ae\u4ef6\u4e86\uff0c\u795d\u5927\u5bb6\u4e00\u6b21\u914d\u7f6e\u6210\u529f\uff01<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u5b89\u88c5\u548c\u914d\u7f6e\u7cfb\u7edf\u7684 mailx \u8fd9\u91cc\u4ee5\u670d\u52a1\u5668\u9996\u9009\u7684\u00a0CentOS 7\u4e3a\u4f8b\uff08\u597d\u50cf\u9ed8\u8ba4 &hellip; <a href=\"https:\/\/blog.espnlol.com\/?p=335\">\u7ee7\u7eed\u9605\u8bfb <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[28],"tags":[],"class_list":["post-335","post","type-post","status-publish","format-standard","hentry","category-zabbix"],"_links":{"self":[{"href":"https:\/\/blog.espnlol.com\/index.php?rest_route=\/wp\/v2\/posts\/335","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blog.espnlol.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.espnlol.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.espnlol.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.espnlol.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=335"}],"version-history":[{"count":1,"href":"https:\/\/blog.espnlol.com\/index.php?rest_route=\/wp\/v2\/posts\/335\/revisions"}],"predecessor-version":[{"id":336,"href":"https:\/\/blog.espnlol.com\/index.php?rest_route=\/wp\/v2\/posts\/335\/revisions\/336"}],"wp:attachment":[{"href":"https:\/\/blog.espnlol.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=335"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.espnlol.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=335"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.espnlol.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=335"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}