{"id":12064,"date":"2022-04-26T10:00:00","date_gmt":"2022-04-26T01:00:00","guid":{"rendered":"https:\/\/www.gigas-jp.com\/appnews\/?p=12064"},"modified":"2022-04-25T19:42:30","modified_gmt":"2022-04-25T10:42:30","slug":"a-simple-script-to-send-email-by-smtp-in-python","status":"publish","type":"post","link":"https:\/\/www.gigas-jp.com\/appnews\/archives\/12064","title":{"rendered":"A simple script to send email by SMTP in Python"},"content":{"rendered":"\n<p>Today, I would like to share about sending emails by SMTP with a simple python script. Let\u2019s take a look.<\/p>\n\n\n\n<p>To send smpt emails, we will need just one library smtplib that is a built-in python lib. Here is the code.<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" width=\"791\" height=\"271\" src=\"https:\/\/www.gigas-jp.com\/appnews\/wp-content\/uploads\/sites\/4\/2022\/04\/smtpsend.png\" alt=\"\" class=\"wp-image-12065\" \/><\/figure>\n\n\n\n<p>There are just simple 6 steps.<\/p>\n\n\n\n<p>1. Connect to a SMTP server <strong>[line 3]<\/strong><\/p>\n\n\n\n<p>2. Sending the SMTP \u2018Hello\u2019 Message <strong>[line 4]<\/strong><\/p>\n\n\n\n<p>3. Starting TLS Encryption <strong>[line 5]<\/strong><\/p>\n\n\n\n<p>4. Logging in to the SMTP server <strong>[line 7]<\/strong><\/p>\n\n\n\n<p>5. Sending an Email <strong>[line 8]<\/strong><\/p>\n\n\n\n<p>6. Disconnecting from the SMTP server <strong>[line 11]<\/strong><\/p>\n\n\n\n<p>Note: To send with gmail SMTP, you will need to turn on \u2018Less secure app access\u2019 in your gmail account settings.<\/p>\n\n\n\n<p>This is all for now. Hope you enjoy and can expand to further uses based on that.<\/p>\n\n\n\n<p>By Asahi<\/p>\n<div class='wp_social_bookmarking_light'>\n            <div class=\"wsbl_google_plus_one\"><g:plusone size=\"medium\" annotation=\"none\" href=\"https:\/\/www.gigas-jp.com\/appnews\/archives\/12064\" ><\/g:plusone><\/div>\n            <div class=\"wsbl_hatena_button\"><a href=\"\/\/b.hatena.ne.jp\/entry\/https:\/\/www.gigas-jp.com\/appnews\/archives\/12064\" class=\"hatena-bookmark-button\" data-hatena-bookmark-title=\"A simple script to send email by SMTP in Python\" data-hatena-bookmark-layout=\"standard\" title=\"\u3053\u306e\u30a8\u30f3\u30c8\u30ea\u30fc\u3092\u306f\u3066\u306a\u30d6\u30c3\u30af\u30de\u30fc\u30af\u306b\u8ffd\u52a0\"> <img src=\"\/\/b.hatena.ne.jp\/images\/entry-button\/button-only@2x.png\" alt=\"\u3053\u306e\u30a8\u30f3\u30c8\u30ea\u30fc\u3092\u306f\u3066\u306a\u30d6\u30c3\u30af\u30de\u30fc\u30af\u306b\u8ffd\u52a0\" width=\"20\" height=\"20\" style=\"border: none;\" \/><\/a><script type=\"text\/javascript\" src=\"\/\/b.hatena.ne.jp\/js\/bookmark_button.js\" charset=\"utf-8\" async=\"async\"><\/script><\/div>\n            <div class=\"wsbl_twitter\"><a href=\"https:\/\/twitter.com\/share\" class=\"twitter-share-button\" data-url=\"https:\/\/www.gigas-jp.com\/appnews\/archives\/12064\" data-text=\"A simple script to send email by SMTP in Python\" data-via=\"GIGASJAPAN_APPS\" data-lang=\"ja\">Tweet<\/a><\/div>\n            <div class=\"wsbl_facebook_like\"><div id=\"fb-root\"><\/div><fb:like href=\"https:\/\/www.gigas-jp.com\/appnews\/archives\/12064\" layout=\"button_count\" action=\"like\" width=\"100\" share=\"false\" show_faces=\"false\" ><\/fb:like><\/div>\n            <div class=\"wsbl_facebook_send\"><div id=\"fb-root\"><\/div><fb:send href=\"https:\/\/www.gigas-jp.com\/appnews\/archives\/12064\" colorscheme=\"light\" ><\/fb:send><\/div>\n    <\/div>\n<br class='wp_social_bookmarking_light_clear' \/>\n","protected":false},"excerpt":{"rendered":"<p>Today, I would like to share about sending emails by SMTP with a simple python script. Let\u2019s take a look. To s [&hellip;]<\/p>\n","protected":false},"author":20,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[100],"tags":[],"acf":[],"_links":{"self":[{"href":"https:\/\/www.gigas-jp.com\/appnews\/wp-json\/wp\/v2\/posts\/12064"}],"collection":[{"href":"https:\/\/www.gigas-jp.com\/appnews\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.gigas-jp.com\/appnews\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.gigas-jp.com\/appnews\/wp-json\/wp\/v2\/users\/20"}],"replies":[{"embeddable":true,"href":"https:\/\/www.gigas-jp.com\/appnews\/wp-json\/wp\/v2\/comments?post=12064"}],"version-history":[{"count":2,"href":"https:\/\/www.gigas-jp.com\/appnews\/wp-json\/wp\/v2\/posts\/12064\/revisions"}],"predecessor-version":[{"id":12068,"href":"https:\/\/www.gigas-jp.com\/appnews\/wp-json\/wp\/v2\/posts\/12064\/revisions\/12068"}],"wp:attachment":[{"href":"https:\/\/www.gigas-jp.com\/appnews\/wp-json\/wp\/v2\/media?parent=12064"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.gigas-jp.com\/appnews\/wp-json\/wp\/v2\/categories?post=12064"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.gigas-jp.com\/appnews\/wp-json\/wp\/v2\/tags?post=12064"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}