{"id":15101,"date":"2022-10-04T13:40:34","date_gmt":"2022-10-04T05:40:34","guid":{"rendered":"http:\/\/lrxjmw.cn\/?p=15101"},"modified":"2022-10-04T13:40:37","modified_gmt":"2022-10-04T05:40:37","slug":"linux-ssmtp-mail","status":"publish","type":"post","link":"https:\/\/lrxjmw.cn\/linux-ssmtp-mail.html","title":{"rendered":"SSMTP\u2014\u8ba9Linux\u7cfb\u7edf\u4eceOffice 365\u53d1\u9001\u90ae\u4ef6"},"content":{"rendered":"\n\n\n
\u5bfc\u8bfb<\/td>\nSSMTP \u662f\u4e00\u4e2a\u975e\u5e38\u7b80\u5355\u5b9e\u7528\u7684\u5c0f\u5de5\u5177\uff0c\u5b83\u53ef\u4ee5\u5c06 Linux \u7cfb\u7edf\u7684\u7535\u5b50\u90ae\u4ef6\u4e2d\u7ee7\u5230 Office 365\u3001Google \u6216\u5176\u5b83\u7b2c\u4e09\u65b9 SMTP \u670d\u52a1\u5668\u3002SSMTP \u5e76\u4e0d\u662f\u4e00\u5957\u6210\u719f\u5b8c\u6574\u7684\u90ae\u4ef6\u670d\u52a1\u5668\uff0c\u5b83\u53ea\u80fd\u81ea\u52a8\u5c06\u90ae\u4ef6\u63d0\u4ea4\u5230\u5176\u5b83\u50cf Google\u3001\u817e\u8baf\u3001163\u3001Office 365 \u8fd9\u6837\u7684 SMTP \u670d\u52a1\u5668\u3002\u5728\u672c\u6587\u4e2d\uff0c\u6211\u4eec\u5c06\u4ecb\u7ecd\u5982\u4f55\u914d\u7f6e SSMTP \u901a\u8fc7 Office 365 \u8d26\u6237\u53d1\u9001\u7535\u5b50\u90ae\u4ef6\u3002<\/strong><\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n

<\/p>\n

SSMTP\u5982\u4f55\u5de5\u4f5c<\/strong><\/div>\n

\u5728\u6b63\u5f0f\u5b89\u88c5\u548c\u914d\u7f6e\u4e4b\u524d\uff0c\u6211\u4eec\u5148\u7b80\u8981\u4ecb\u7ecd\u4e0b SSMTP \u662f\u5982\u4f55\u5de5\u4f5c\u7684\u3002SSMTP \u53ef\u4ee5\u88ab\u5b89\u88c5\u5230\u4efb\u610f Linux \u7cfb\u7edf\u5f53\u4e2d\uff0c\u4e00\u65e6\u914d\u7f6e\u5b8c\u6210\uff0c\u6240\u6709\u6765\u81ea root\u3001nobody \u6216\u5176\u5b83\u5e94\u7528\u7a0b\u5e8f\u53d1\u9001\u7684\u90ae\u4ef6\u90fd\u53ef\u4ee5\u901a\u8fc7 SSMTP \u8fdb\u884c\u8f6c\u53d1\u3002\u6211\u4eec\u4e5f\u53ef\u4ee5\u914d\u7f6e PHP\u3001Python,\u3001Ruby \u7b49\u5e94\u7528\u7a0b\u5e8f\u7684\u90ae\u4ef6\u90fd\u4f7f\u7528\u8be5\u7a0b\u5e8f\u8fdb\u884c\u8f6c\u53d1\u3002\u7b80\u800c\u8a00\u4e4b\uff0c\u4f60\u53ef\u4ee5\u5c06 SSMTP \u7406\u89e3\u4e3a Linux \u4e2d\u7684 Mailhub\u3002<\/p>\n

\u5728 Mailhub \u4e2d\u53ef\u4ee5\u914d\u7f6e\u548c\u6307\u5b9a Gmail SMTP \u670d\u52a1\u5668\u6216 Microsof Office365 SMTP \u670d\u52a1\u5668\u5730\u5740\uff0c\u4e00\u65e6\u4e3a\u5176\u6307\u5b9a\u597d\u670d\u52a1\u5668\u548c\u7535\u5b50\u90ae\u4ef6\u5730\u5740\uff0c\u5b83\u4fbf\u53ef\u4ee5\u76f4\u63a5\u901a\u8fc7\u4e91\u670d\u52a1\u53d1\u9001\u90ae\u4ef6\u3002<\/p>\n

\u5b89\u88c5SSMTP<\/strong><\/div>\n

SSMTP \u5b89\u88c5\u975e\u5e38\u7b80\u5355\uff0c\u5f88\u591a Linux \u6e90\u4e2d\u90fd\u6709\u63d0\u4f9b\uff0c\u57fa\u4e8e RHEL \u7684 Linux \u53d1\u884c\u7248\uff08RHEL\/CentOS\/Fedora\uff09\u53ef\u4ee5\u4f7f\u7528\u5982\u4e0b\u547d\u4ee4\u5b89\u88c5\uff1a<\/p>\n

yum install ssmtp<\/pre>\n

Ubuntu \u548c Debian \u670d\u52a1\u5668\u53ef\u4ee5\u4f7f\u7528\u5982\u4e0b\u547d\u4ee4\u5b89\u88c5\uff1a<\/p>\n

sudo apt-get install ssmtp<\/pre>\n

\u5b89\u88c5\u5b8c\u6210\u540e\u6240\u6709\u914d\u7f6e\u6587\u4ef6\u90fd\u4f1a\u5199\u5165\u5230\/etc\/ssmtp\/<\/span>\u76ee\u5f55\u5f53\u4e2d\u3002<\/p>\n

\u4f7f\u7528SSMTP\u66ff\u4ee3sendmail\/postfix<\/strong><\/div>\n

\u4e00\u822c\u60c5\u51b5\u4e0b\uff0c\u5f88\u591a Linux \u53d1\u884c\u7248\u90fd\u4f7f\u7528 Sendmail \u6216 Postfix \u4f5c\u4e3a\u9ed8\u8ba4\u4e86\u7535\u5b50\u90ae\u4ef6\u7cfb\u7edf\uff0c\u6211\u4eec\u4e4b\u6240\u4ee5\u4f7f\u7528 SSMTP \u5c31\u662f\u4e3a\u4e86\u4f7f\u7528\u5916\u90e8 SMTP \u4e2d\u7ee7\uff0c\u56e0\u6b64\u8981\u5c06 SSMTP \u914d\u7f6e\u4e3a\u7cfb\u7edf\u9ed8\u8ba4\uff0c\u9996\u5148\u5c31\u5f97\u505c\u7528 sendmail \u6216 postfix \u670d\u52a1\u3002<\/p>\n

systemctl stop sendmail\r\nsystemctl stop postfix<\/pre>\n

\u5982\u679c\u4f60\u4f7f\u7528\u8f83\u65e9\u7248\u672c Linux\uff0c\u53ef\u4ee5\u4f7f\u7528\u5982\u4e0b\u547d\u4ee4\u505c\u7528\u670d\u52a1\uff1a<\/p>\n

service sendmail stop\r\nservice postfix stop<\/pre>\n

\u6ce8\u610f\uff1a\u8fd8\u9700\u505c\u6b62 sendmail \u6216 postfix \u670d\u52a1\u968f\u7cfb\u7edf\u542f\u52a8\u54e6\uff0c\u6700\u597d\u8fd8\u662f\u76f4\u63a5\u5378\u8f7d\u6389\u5427\u3002<\/p>\n

\u914d\u7f6eSSMTP\u4f7f\u7528Office365\u90ae\u4ef6\u5730\u5740<\/strong><\/div>\n

\u4f7f\u7528 vim \u6216\u4f60\u559c\u6b22\u7684\u4efb\u610f\u7f16\u8f91\u5668\u5bf9 \/etc\/ssmtp\/ssmtp.conf<\/span> \u6587\u4ef6\u8fdb\u884c\u7f16\u8f91\uff0c\u6211\u4eec\u4ee5 Office 365 \u7684 SMTP \u670d\u52a1\u5668\u4e3a\u4f8b\uff0c\u5982\u679c\u4f60\u4f7f\u7528\u5176\u5b83 SMTP \u8bf7\u81ea\u884c\u6309\u670d\u52a1\u5546\u7684\u5b98\u65b9\u6587\u6863\u8fdb\u884c\u4fee\u6539\uff1a<\/p>\n

root=admin@sysgeek.cn\r\nmailhub=smtp.office365.com:587\r\nAuthUser=admin@sysgeek.cn\r\nAuthPass=XXXXX\r\nUseTLS=YES\r\nUseSTARTTLS=YES\r\nFromLineOverride=YES\r\nRewriteDomain:sysgeek.cn<\/pre>\n


\n\u914d\u7f6e\u6587\u4ef6\u4fee\u6539\u5e76\u4fdd\u5b58\u597d\u4e4b\u540e\u6211\u4eec\u5c31\u53ef\u4ee5\u7528\u4e0a Office 365 \u63d0\u4f9b\u7684\u53ef\u9760\u90ae\u4ef6\u670d\u52a1\u4e86\uff0c\u73b0\u5728\u5148\u7528\u5982\u4e0b\u547d\u4ee4\u5148\u53d1\u4e2a\u6d4b\u8bd5\u90ae\u4ef6\u6765\u770b\u770b\uff1a<\/p>\n

echo \"This is a test e-mail\" | mail -s \"Test Email\" XXXX@qq.com<\/pre>\n


\n\u5982\u679c\u4f60\u5728\u53d1\u9001\u6d4b\u8bd5\u90ae\u4ef6\u65f6\u9047\u5230\u7c7b\u4f3c\u5982\u4e0b\u63d0\u793a\uff1a<\/p>\n

ssmtp: Cannot open mail.server.com:25<\/pre>\n

\u90a3\u662f\u56e0\u4e3a ssmtp \u9ed8\u8ba4\u4f1a\u5c1d\u8bd5\u4f7f\u7528\u6807\u51c6\u7684 SMTP 25 \u7aef\u53e3\u53bb\u8fde\u63a5\u90ae\u4ef6\u670d\u52a1\u5668\uff0c\u5982\u679c\u4f60\u6240\u4f7f\u7528\u7684 SMTP \u4e2d\u7ee7\u50cf Gmail \u6216 Office 365 \u8fd9\u6837\u91c7\u7528\u4e86 TLS \u52a0\u5bc6\u7684\u975e\u6807\u51c6\u7aef\u53e3\uff0c\u8fd8\u9700\u8981\u5230 \/etc\/ssmtp\/revaliases<\/span> \u914d\u7f6e\u6587\u4ef6\u4e2d\u5bf9\u53d1\u4ef6\u4eba\u3001\u670d\u52a1\u5668\u5730\u5740\u548c\u7aef\u53e3\u8fdb\u884c\u6307\u660e\uff1a
\n<\/p>\n

\n

\u539f\u6587\u6765\u81ea\uff1ahttps:\/\/www.sysgeek.cn\/install-ssmtp-to-send-emails-from-office365\/<\/a><\/p>\n

\u672c\u6587\u5730\u5740\uff1a http:\/\/lrxjmw.cn\/linux-ssmtp-mail.html<\/a>\u7f16\u8f91\uff1a\u674e\u653f\u5c27\uff0c\u5ba1\u6838\u5458\uff1a\u5cb3\u6c38<\/span><\/p>\n<\/blockquote>\n","protected":false},"excerpt":{"rendered":"

\u5bfc\u8bfb SSMTP \u662f\u4e00\u4e2a\u975e\u5e38\u7b80\u5355\u5b9e\u7528\u7684\u5c0f\u5de5\u5177\uff0c\u5b83\u53ef\u4ee5\u5c06 Linux \u7cfb\u7edf\u7684\u7535\u5b50\u90ae\u4ef6\u4e2d\u7ee7\u5230 Office 365 […]<\/p>\n","protected":false},"author":63,"featured_media":15138,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[55],"tags":[],"class_list":["post-15101","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-thread"],"acf":[],"_links":{"self":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts\/15101","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/users\/63"}],"replies":[{"embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/comments?post=15101"}],"version-history":[{"count":26,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts\/15101\/revisions"}],"predecessor-version":[{"id":254266,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts\/15101\/revisions\/254266"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/media\/15138"}],"wp:attachment":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/media?parent=15101"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/categories?post=15101"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/tags?post=15101"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}