{"id":3345,"date":"2022-10-16T14:49:02","date_gmt":"2022-10-16T05:49:02","guid":{"rendered":"https:\/\/apr20.net\/?p=3345"},"modified":"2022-10-16T14:49:02","modified_gmt":"2022-10-16T05:49:02","slug":"python-smtplib%e3%81%a7%e3%83%a1%e3%83%bc%e3%83%ab%e9%80%81%e4%bf%a1","status":"publish","type":"post","link":"https:\/\/apr20.net\/?p=3345","title":{"rendered":"Python smtplib\u3067\u30e1\u30fc\u30eb\u9001\u4fe1"},"content":{"rendered":"<p>[php]import smtplib<br \/>\nfrom email.mime.text import MIMEText<\/p>\n<p>smtp_setting = {<br \/>\n    &#8216;host&#8217;: &#8216;xxxxx.xserver.jp&#8217;,<br \/>\n    &#8216;port&#8217;: 465,<br \/>\n    &#8216;account&#8217;: &#8216;sample@dattesar.com&#8217;,<br \/>\n    &#8216;password&#8217;: &#8216;dattesar_pass&#8217;<br \/>\n}<\/p>\n<p>email_content = {<br \/>\n    &#8216;To&#8217;: &#8216;test@dattesar.com&#8217;,<br \/>\n    &#8216;From&#8217;: &#8216;sample@dattesar.com&#8217;,<br \/>\n    &#8216;Subject&#8217;: &#8216;\u30c6\u30b9\u30c8\u30e1\u30fc\u30eb&#8217;,<br \/>\n    &#8216;Text&#8217;: &#8216;\u3053\u306e\u30e1\u30fc\u30eb\u306fPython\u3067\u9001\u4fe1\u3057\u3066\u3044\u307e\u3059\u3002&#8217;<br \/>\n}<\/p>\n<p>msg = MIMEText(email_content[&#8216;Text&#8217;], &#8216;plain&#8217;, &#8216;utf-8&#8217;)<br \/>\nmsg[&#8216;Subject&#8217;] = email_content[&#8216;Subject&#8217;]<br \/>\nmsg[&#8216;From&#8217;] = email_content[&#8216;From&#8217;]<br \/>\nmsg[&#8216;To&#8217;] = email_content[&#8216;To&#8217;]<\/p>\n<p>with smtplib.SMTP_SSL(smtp_setting[&#8216;host&#8217;], smtp_setting[&#8216;port&#8217;], timeout=10) as smtp:<br \/>\n    smtp.login(smtp_setting[&#8216;account&#8217;], smtp_setting[&#8216;password&#8217;])<br \/>\n    smtp.send_message(msg)<br \/>\n    smtp.quit()[\/php]<\/p>\n","protected":false},"excerpt":{"rendered":"<p>[php]import smtplib from email.mime.text&#8230;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[21],"tags":[],"class_list":["post-3345","post","type-post","status-publish","format-standard","hentry","category-python"],"_links":{"self":[{"href":"https:\/\/apr20.net\/index.php?rest_route=\/wp\/v2\/posts\/3345","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/apr20.net\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/apr20.net\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/apr20.net\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/apr20.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=3345"}],"version-history":[{"count":0,"href":"https:\/\/apr20.net\/index.php?rest_route=\/wp\/v2\/posts\/3345\/revisions"}],"wp:attachment":[{"href":"https:\/\/apr20.net\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=3345"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/apr20.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=3345"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/apr20.net\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=3345"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}