

{"id":15017,"date":"2018-05-15T05:46:19","date_gmt":"2018-05-15T00:16:19","guid":{"rendered":"https:\/\/data-flair.training\/blogs\/?p=15017"},"modified":"2026-04-25T12:28:36","modified_gmt":"2026-04-25T06:58:36","slug":"python-send-email","status":"publish","type":"post","link":"https:\/\/data-flair.training\/blogs\/python-send-email\/","title":{"rendered":"Python Send Email Via SMTP | SMTP Server"},"content":{"rendered":"<div class='__iawmlf-post-loop-links' style='display:none;' data-iawmlf-post-links='[{&quot;id&quot;:1949,&quot;href&quot;:&quot;https:\\\/\\\/docs.python.org\\\/2\\\/library\\\/email-examples.html&quot;,&quot;archived_href&quot;:&quot;&quot;,&quot;redirect_href&quot;:&quot;&quot;,&quot;checks&quot;:[],&quot;broken&quot;:false,&quot;last_checked&quot;:null,&quot;process&quot;:&quot;new&quot;}]'><\/div>\n<p>Imagine Python as your own personal messenger. Instead of manually writing a letter, you can now write some lines of code that act as an instructor to tell your computer exactly how to pack, address, and deliver your message quickly.<\/p>\n<p><span style=\"font-weight: 400\">In this tutorial on the <strong><a href=\"https:\/\/data-flair.training\/blogs\/python-tutorial-for-beginners\/\">Python Programming Language<\/a><\/strong>,<\/span>\u00a0you\u2019ll learn about:<\/p>\n<ul>\n<li>How can you use tools like smtplib to do heavy tasks.<\/li>\n<li>Connect to a server like SMTP to send your mail.<\/li>\n<li>Send everything from a basic hello to fancy fonts, colors, and messages.<\/li>\n<\/ul>\n<p>At last, we are going to discuss how Python sends HTML Email using SMTP.<\/p>\n<p>So, let&#8217;s discuss the process of sending mail in Python via SMTP.<\/p>\n<div id=\"attachment_15155\" style=\"width: 1210px\" class=\"wp-caption aligncenter\"><a href=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/05\/Sending-Mail-with-Python-3.jpg\"><img loading=\"lazy\" decoding=\"async\" aria-describedby=\"caption-attachment-15155\" class=\"wp-image-15155 size-full\" src=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/05\/Sending-Mail-with-Python-3.jpg\" alt=\"Sending Mail with Python 3 via SMTP\" width=\"1200\" height=\"628\" srcset=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/05\/Sending-Mail-with-Python-3.jpg 1200w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/05\/Sending-Mail-with-Python-3-150x79.jpg 150w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/05\/Sending-Mail-with-Python-3-300x157.jpg 300w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/05\/Sending-Mail-with-Python-3-768x402.jpg 768w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/05\/Sending-Mail-with-Python-3-1024x536.jpg 1024w\" sizes=\"auto, (max-width: 1200px) 100vw, 1200px\" \/><\/a><p id=\"caption-attachment-15155\" class=\"wp-caption-text\">Sending Mail with Python 3 via SMTP<\/p><\/div>\n<h3><span style=\"font-weight: 400\">What is an SMTP Server?<\/span><\/h3>\n<p><span style=\"font-weight: 400\"><em>Simple Mail Transfer Protocol<\/em> is an application-layer protocol in the OSI model. It lets a user send mail to another. Since this is a push protocol, we can use it to send an email. At the receiver, this mail is retrieved using protocols <strong>POP (Post Office Protocol)<\/strong> and <strong>IMAP (Internet Message Access Protocol).<\/strong><\/span><\/p>\n<div id=\"attachment_15156\" style=\"width: 1210px\" class=\"wp-caption aligncenter\"><a href=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/05\/smtp.png\"><img loading=\"lazy\" decoding=\"async\" aria-describedby=\"caption-attachment-15156\" class=\"wp-image-15156 size-full\" src=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/05\/smtp.png\" alt=\"SMTP\" width=\"1200\" height=\"628\" srcset=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/05\/smtp.png 1200w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/05\/smtp-150x79.png 150w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/05\/smtp-300x157.png 300w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/05\/smtp-768x402.png 768w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/05\/smtp-1024x536.png 1024w\" sizes=\"auto, (max-width: 1200px) 100vw, 1200px\" \/><\/a><p id=\"caption-attachment-15156\" class=\"wp-caption-text\">Python Send Email-\u00a0SMTP Server<\/p><\/div>\n<p><span style=\"font-weight: 400\">We need to start a server that is always listening for a request. As a client, we open a TCP connection to this server and then send the mail. When the server listens for a TCP connection from a client, it initiates a connection on port 587.<\/span><br \/>\n<strong><a href=\"https:\/\/data-flair.training\/blogs\/python-packages\/\">Have a look at\u00a0Python Packages Comprehensive Guide<\/a><\/strong><\/p>\n<h3><span style=\"font-weight: 400\">Python Send Email Using smtplib Module<\/span><\/h3>\n<p><span style=\"font-weight: 400\">We\u2019ll use the smtplib module for sending Python Email. This is our Python SMTP script to send mail:<\/span><\/p>\n<pre class=\"EnlighterJSRAW\">&gt;&gt;&gt; import smtplib\r\n&gt;&gt;&gt; sender='thesender@gmail.com'\r\n&gt;&gt;&gt; receiver='whicheverreceiver@gmail.com'\r\n&gt;&gt;&gt; password=\u2019&lt;put your password here&gt;'\r\n&gt;&gt;&gt; smtpserver=smtplib.SMTP(\"smtp.gmail.com\",587)\r\n&gt;&gt;&gt; smtpserver.ehlo()\r\n&gt;&gt;&gt; smtpserver.starttls()\r\n&gt;&gt;&gt; smtpserver.ehlo\r\n&gt;&gt;&gt; smtpserver.login(sender,password)\r\n&gt;&gt;&gt; msg='Subject:Demo\\nThis is a demo\r\n&gt;&gt;&gt; smtpserver.sendmail(sender,receiver,msg)\r\n&gt;&gt;&gt; print('Sent')\r\n&gt;&gt;&gt; smtpserver.close()<\/pre>\n<p><span style=\"font-weight: 400\">Save this as a .py script, and run this to find this output:<\/span><\/p>\n<pre class=\"EnlighterJSRAW\">&gt;&gt;&gt;<\/pre>\n<p>RESTART:<\/p>\n<p>C:\/Users\/lifei\/AppData\/Local\/Programs\/Python\/Python36-32\/demomail.py Sent<\/p>\n<p><span style=\"font-weight: 400\">This may make your Gmail ask you for access to less secure apps if you\u2019re using Gmail. You will need to turn this ON temporarily for this to work.<\/span><\/p>\n<div id=\"attachment_15157\" style=\"width: 1252px\" class=\"wp-caption aligncenter\"><a href=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/05\/access.jpg\"><img loading=\"lazy\" decoding=\"async\" aria-describedby=\"caption-attachment-15157\" class=\"wp-image-15157 size-full\" src=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/05\/access.jpg\" alt=\"SMTP\" width=\"1242\" height=\"2144\" srcset=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/05\/access.jpg 1242w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/05\/access-87x150.jpg 87w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/05\/access-174x300.jpg 174w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/05\/access-768x1326.jpg 768w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/05\/access-593x1024.jpg 593w\" sizes=\"auto, (max-width: 1242px) 100vw, 1242px\" \/><\/a><p id=\"caption-attachment-15157\" class=\"wp-caption-text\">Python Send Email using smtplib Module<\/p><\/div>\n<h3>How Does SMTP Work in Python?<\/h3>\n<p><span style=\"font-weight: 400\">First, we import smtplib.<\/span><\/p>\n<pre class=\"EnlighterJSRAW\">&gt;&gt;&gt; import smtplib<\/pre>\n<p><span style=\"font-weight: 400\">Then, we set three strings- the sender\u2019s and receiver\u2019s email addresses, and the sender\u2019s password. Put your password for your mail ID in the string for a password.<\/span><\/p>\n<pre class=\"EnlighterJSRAW\">&gt;&gt;&gt; sender='thesender@gmail.com'\r\n&gt;&gt;&gt; receiver='whicheverreceiver@gmail.com'\r\n&gt;&gt;&gt; password=\u2019&lt;put your password here&gt;'<\/pre>\n<p><span style=\"font-weight: 400\">Then, we create a server object using smptlib.SMTP(). We use port 587 here, and the domain smtp.gmail.com.<\/span><\/p>\n<pre class=\"EnlighterJSRAW\">&gt;&gt;&gt; smtpserver=smtplib.SMTP(\"smtp.gmail.com\",587)<\/pre>\n<p><span style=\"font-weight: 400\">On this, we call the ehlo() method for Extended Hello. This lets the server identify the client, and also tells it that it must use the ESMTP (Extended SMTP) Protocol.<\/span><\/p>\n<p><strong><a href=\"https:\/\/data-flair.training\/blogs\/python-datetime-module\/\">Read\u00a0Python Datetime Module with Quick Examples<\/a><\/strong><\/p>\n<pre class=\"EnlighterJSRAW\">&gt;&gt;&gt; smtpserver.ehlo()\r\n<\/pre>\n<p><span style=\"font-weight: 400\">Then, we call starttls() to use a Transport Layer Security connection.<\/span><\/p>\n<pre class=\"EnlighterJSRAW\">&gt;&gt;&gt; smtpserver.starttls()<\/pre>\n<p><span style=\"font-weight: 400\">And then we call ehlo() again.<\/span><\/p>\n<pre class=\"EnlighterJSRAW\">&gt;&gt;&gt; smtpserver.ehlo<\/pre>\n<p><span style=\"font-weight: 400\">Then, we call the login() method on this server object. To this, we pass the parameters <\/span><i><span style=\"font-weight: 400\">sender<\/span><\/i><span style=\"font-weight: 400\"> and <\/span><i><span style=\"font-weight: 400\">password<\/span><\/i><span style=\"font-weight: 400\"> to let the client gain access from the Gmail server to send an email.<\/span><\/p>\n<pre class=\"EnlighterJSRAW\">&gt;&gt;&gt; smtpserver.login(sender,password)<\/pre>\n<p><span style=\"font-weight: 400\">Then, we decide on the message to send. To set the subject for the message, we do:<\/span><\/p>\n<pre class=\"EnlighterJSRAW\">&gt;&gt;&gt; msg='Subject:Demo\\nThis is a demo'<\/pre>\n<p><span style=\"font-weight: 400\">Now, we call the method sendmail() to send the mail in Python. To this, we pass <\/span><i><span style=\"font-weight: 400\">sender<\/span><\/i><span style=\"font-weight: 400\">, <\/span><i><span style=\"font-weight: 400\">receiver<\/span><\/i><span style=\"font-weight: 400\">, and <\/span><i><span style=\"font-weight: 400\">msg<\/span><\/i><span style=\"font-weight: 400\">.<\/span><\/p>\n<pre class=\"EnlighterJSRAW\">&gt;&gt;&gt; smtpserver.sendmail(sender,receiver,msg)<\/pre>\n<p>Finally, we print a success receipt to the client and then exit.<\/p>\n<pre class=\"EnlighterJSRAW\">&gt;&gt;&gt; print('Sent')\r\n&gt;&gt;&gt; smtpserver.close()\r\n<\/pre>\n<p><span style=\"font-family: Verdana, Geneva, sans-serif\">Also, if you type in the incorrect password, you will come across this exception:<\/span><\/p>\n<p><strong><a href=\"https:\/\/data-flair.training\/blogs\/python-variable-scope\/\">Explore Python Variable Scope \u2013 Local, Global, Built-in, Enclosed<\/a><\/strong><\/p>\n<pre class=\"EnlighterJSRAW\">&gt;&gt;&gt;\r\n\r\n<\/pre>\n<p>RESTART:<\/p>\n<p>C:\/Users\/lifei\/AppData\/Local\/Programs\/Python\/Python36-32\/demomail.py Traceback (most recent call last): File &#8220;C:\/Users\/lifei\/AppData\/Local\/Programs\/Python\/Python36-32\/demomail.py&#8221;, line 10, in &lt;module&gt; smtpserver.login(sender,password) File<\/p>\n<p>&#8220;C:\\Users\\lifei\\AppData\\Local\\Programs\\Python\\Python36-32\\lib\\smtplib.py&#8221;, line 729, in login raise last_exception File &#8220;C:\\Users\\lifei\\AppData\\Local\\Programs\\Python\\Python36-32\\lib\\smtplib.py&#8221;, line 720, in login initial_response_ok=initial_response_ok) File<\/p>\n<p>&#8220;C:\\Users\\lifei\\AppData\\Local\\Programs\\Python\\Python36-32\\lib\\smtplib.py&#8221;, line 641, in auth raise SMTPAuthenticationError(code, resp) smtplib.SMTPAuthenticationError: (535, b&#8217;5.7.8 Username and Password not accepted. Learn more at\\n5.7.8 https:\/\/support.google.com\/mail\/?p=BadCredentials z62sm38593861pff.57 &#8211; gsmt<\/p>\n<h3><span style=\"font-family: Georgia, Georgia, serif\">How to Send HTML Email in Python?<\/span><\/h3>\n<p><span style=\"font-weight: 400\">For sending an HTML email, you can also configure your message to be able to embed simple HTML code in it.<\/span><br \/>\n<span style=\"font-weight: 400\">Import smtplib<\/span><\/p>\n<pre class=\"EnlighterJSRAW\">&gt;&gt;&gt; sender='thesender@gmail.com'\r\n&gt;&gt;&gt; receiver=\u2019whicheverreceiver@gmail.com'\r\n&gt;&gt;&gt; password='&lt;your password&gt;'\r\n&gt;&gt;&gt; smtpserver=smtplib.SMTP(\"smtp.gmail.com\",587)\r\n&gt;&gt;&gt; smtpserver.ehlo()\r\n&gt;&gt;&gt; smtpserver.starttls()\r\n&gt;&gt;&gt; smtpserver.ehlo\r\n&gt;&gt;&gt; smtpserver.login(sender,password)\r\n&gt;&gt;&gt; msg=\"\"\"From: Ayushi\r\nTo: Ruchi\r\nMIME-Version: 1.0\r\nContent-type: text\/html\r\nSubject:Demo\r\nThis is a demo&lt;br\/&gt;&lt;p align=\"center\"&gt;Hi&lt;\/p&gt;&lt;hr\/&gt;\"\"\"\r\n&gt;&gt;&gt; smtpserver.sendmail(sender,receiver,msg)\r\n&gt;&gt;&gt; print('Sent')\r\n&gt;&gt;&gt; smtpserver.close()<\/pre>\n<p><span style=\"font-weight: 400\">So, we received this email in the receiving inbox.<\/span><\/p>\n<div id=\"attachment_15158\" style=\"width: 571px\" class=\"wp-caption aligncenter\"><a href=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/05\/html.jpg\"><img loading=\"lazy\" decoding=\"async\" aria-describedby=\"caption-attachment-15158\" class=\"wp-image-15158 size-full\" src=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/05\/html.jpg\" alt=\"SMTP\" width=\"561\" height=\"579\" srcset=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/05\/html.jpg 561w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/05\/html-145x150.jpg 145w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/05\/html-291x300.jpg 291w\" sizes=\"auto, (max-width: 561px) 100vw, 561px\" \/><\/a><p id=\"caption-attachment-15158\" class=\"wp-caption-text\">SMTP- Sending a HTML E-mail<\/p><\/div>\n<p>So, this was all about Python sending an email using the SMTP server. Hope you like our explanation.<\/p>\n<p><strong><a href=\"https:\/\/data-flair.training\/blogs\/python-closure\/\">Learn Python Closure \u2013 Nested Functions and Nonlocal Variables<\/a><\/strong><\/p>\n<h3><span style=\"font-weight: 400\">Conclusion<\/span><\/h3>\n<p><span style=\"font-weight: 400\">Hence, in this <strong><a href=\"https:\/\/data-flair.training\/blogs\/best-python-books\/\">Python<\/a><\/strong> Send Email tutorial, we learn how we can send an email using Python with the SMTP module. Hence, now we have an understanding of the SMTP server in Python. Moreover, we discussed the process of sending an email using the smtplib module. Finally, we saw how to send an HTML email. Furthermore, if you have any queries, feel free to ask in the comments section.<\/span><br \/>\n<strong><a href=\"https:\/\/docs.python.org\/2\/library\/email-examples.html\">For reference<\/a><\/strong><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Imagine Python as your own personal messenger. Instead of manually writing a letter, you can now write some lines of code that act as an instructor to tell your computer exactly how to pack,&#46;&#46;&#46;<\/p>\n","protected":false},"author":5,"featured_media":15950,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[46],"tags":[10343,10827,10828,10829,12722,12723,12883,12964,12965,12966,12967,12968],"class_list":["post-15017","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-python","tag-python-3-send-email","tag-python-send-email","tag-python-send-email-via-smtp","tag-python-send-mail","tag-send-an-html-email","tag-send-mail-using-python","tag-simple-mail-transfer-protocol","tag-smtp","tag-smtp-module","tag-smtp-server","tag-smtplib","tag-smtplib-module"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.4 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>Python Send Email Via SMTP | SMTP Server - DataFlair<\/title>\n<meta name=\"description\" content=\"SMTP module, Python send Email Via SMTP, working of smtp for sending an email, Sending an HTML E-mail, Python Script, smtplib module\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/data-flair.training\/blogs\/python-send-email\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Python Send Email Via SMTP | SMTP Server - DataFlair\" \/>\n<meta property=\"og:description\" content=\"SMTP module, Python send Email Via SMTP, working of smtp for sending an email, Sending an HTML E-mail, Python Script, smtplib module\" \/>\n<meta property=\"og:url\" content=\"https:\/\/data-flair.training\/blogs\/python-send-email\/\" \/>\n<meta property=\"og:site_name\" content=\"DataFlair\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/DataFlairWS\/\" \/>\n<meta property=\"article:published_time\" content=\"2018-05-15T00:16:19+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2026-04-25T06:58:36+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/05\/Sending-Mail-with-Python-3-1.jpg\" \/>\n\t<meta property=\"og:image:width\" content=\"1200\" \/>\n\t<meta property=\"og:image:height\" content=\"628\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/jpeg\" \/>\n<meta name=\"author\" content=\"DataFlair Team\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@DataFlairWS\" \/>\n<meta name=\"twitter:site\" content=\"@DataFlairWS\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"DataFlair Team\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"5 minutes\" \/>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Python Send Email Via SMTP | SMTP Server - DataFlair","description":"SMTP module, Python send Email Via SMTP, working of smtp for sending an email, Sending an HTML E-mail, Python Script, smtplib module","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/data-flair.training\/blogs\/python-send-email\/","og_locale":"en_US","og_type":"article","og_title":"Python Send Email Via SMTP | SMTP Server - DataFlair","og_description":"SMTP module, Python send Email Via SMTP, working of smtp for sending an email, Sending an HTML E-mail, Python Script, smtplib module","og_url":"https:\/\/data-flair.training\/blogs\/python-send-email\/","og_site_name":"DataFlair","article_publisher":"https:\/\/www.facebook.com\/DataFlairWS\/","article_published_time":"2018-05-15T00:16:19+00:00","article_modified_time":"2026-04-25T06:58:36+00:00","og_image":[{"width":1200,"height":628,"url":"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/05\/Sending-Mail-with-Python-3-1.jpg","type":"image\/jpeg"}],"author":"DataFlair Team","twitter_card":"summary_large_image","twitter_creator":"@DataFlairWS","twitter_site":"@DataFlairWS","twitter_misc":{"Written by":"DataFlair Team","Est. reading time":"5 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/data-flair.training\/blogs\/python-send-email\/#article","isPartOf":{"@id":"https:\/\/data-flair.training\/blogs\/python-send-email\/"},"author":{"name":"DataFlair Team","@id":"https:\/\/data-flair.training\/blogs\/#\/schema\/person\/7f83c342f5d1632d6f7b4b0b0f447823"},"headline":"Python Send Email Via SMTP | SMTP Server","datePublished":"2018-05-15T00:16:19+00:00","dateModified":"2026-04-25T06:58:36+00:00","mainEntityOfPage":{"@id":"https:\/\/data-flair.training\/blogs\/python-send-email\/"},"wordCount":840,"commentCount":1,"publisher":{"@id":"https:\/\/data-flair.training\/blogs\/#organization"},"image":{"@id":"https:\/\/data-flair.training\/blogs\/python-send-email\/#primaryimage"},"thumbnailUrl":"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/05\/Sending-Mail-with-Python-3-1.jpg","keywords":["python 3 send email","Python send Email","Python send Email via SMTP","python send mail","send an HTML email","send mail using python","simple mail transfer protocol","SMTP","SMTP module","SMTP server","smtplib","smtplib Module"],"articleSection":["Python Tutorials"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/data-flair.training\/blogs\/python-send-email\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/data-flair.training\/blogs\/python-send-email\/","url":"https:\/\/data-flair.training\/blogs\/python-send-email\/","name":"Python Send Email Via SMTP | SMTP Server - DataFlair","isPartOf":{"@id":"https:\/\/data-flair.training\/blogs\/#website"},"primaryImageOfPage":{"@id":"https:\/\/data-flair.training\/blogs\/python-send-email\/#primaryimage"},"image":{"@id":"https:\/\/data-flair.training\/blogs\/python-send-email\/#primaryimage"},"thumbnailUrl":"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/05\/Sending-Mail-with-Python-3-1.jpg","datePublished":"2018-05-15T00:16:19+00:00","dateModified":"2026-04-25T06:58:36+00:00","description":"SMTP module, Python send Email Via SMTP, working of smtp for sending an email, Sending an HTML E-mail, Python Script, smtplib module","breadcrumb":{"@id":"https:\/\/data-flair.training\/blogs\/python-send-email\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/data-flair.training\/blogs\/python-send-email\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/data-flair.training\/blogs\/python-send-email\/#primaryimage","url":"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/05\/Sending-Mail-with-Python-3-1.jpg","contentUrl":"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/05\/Sending-Mail-with-Python-3-1.jpg","width":1200,"height":628,"caption":"Python send Email via SMTP"},{"@type":"BreadcrumbList","@id":"https:\/\/data-flair.training\/blogs\/python-send-email\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Blog Home","item":"https:\/\/data-flair.training\/blogs\/"},{"@type":"ListItem","position":2,"name":"Python Tutorials","item":"https:\/\/data-flair.training\/blogs\/category\/python\/"},{"@type":"ListItem","position":3,"name":"Python Send Email Via SMTP | SMTP Server"}]},{"@type":"WebSite","@id":"https:\/\/data-flair.training\/blogs\/#website","url":"https:\/\/data-flair.training\/blogs\/","name":"DataFlair","description":"Learn Today. Lead Tomorrow.","publisher":{"@id":"https:\/\/data-flair.training\/blogs\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/data-flair.training\/blogs\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/data-flair.training\/blogs\/#organization","name":"DataFlair","url":"https:\/\/data-flair.training\/blogs\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/data-flair.training\/blogs\/#\/schema\/logo\/image\/","url":"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2016\/07\/Data-Flair.png","contentUrl":"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2016\/07\/Data-Flair.png","width":106,"height":48,"caption":"DataFlair"},"image":{"@id":"https:\/\/data-flair.training\/blogs\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/DataFlairWS\/","https:\/\/x.com\/DataFlairWS","https:\/\/www.linkedin.com\/company\/dataflair-web-services-pvt-ltd\/","https:\/\/www.youtube.com\/user\/DataFlairWS"]},{"@type":"Person","@id":"https:\/\/data-flair.training\/blogs\/#\/schema\/person\/7f83c342f5d1632d6f7b4b0b0f447823","name":"DataFlair Team","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/secure.gravatar.com\/avatar\/4cf3a74600d131330b8c481d519afd1574093ed89f6d3396a95393ad223eb7cd?s=96&d=mm&r=g","url":"https:\/\/secure.gravatar.com\/avatar\/4cf3a74600d131330b8c481d519afd1574093ed89f6d3396a95393ad223eb7cd?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/4cf3a74600d131330b8c481d519afd1574093ed89f6d3396a95393ad223eb7cd?s=96&d=mm&r=g","caption":"DataFlair Team"},"description":"DataFlair Team creates expert-level guides on programming, Java, Python, C++, DSA, AI, ML, data Science, Android, Flutter, MERN, Web Development, and technology. Our goal is to empower learners with easy-to-understand content. Explore our resources for career growth and practical learning.","url":"https:\/\/data-flair.training\/blogs\/author\/dfteam1\/"}]}},"amp_enabled":true,"_links":{"self":[{"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/posts\/15017","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/users\/5"}],"replies":[{"embeddable":true,"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/comments?post=15017"}],"version-history":[{"count":8,"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/posts\/15017\/revisions"}],"predecessor-version":[{"id":147886,"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/posts\/15017\/revisions\/147886"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/media\/15950"}],"wp:attachment":[{"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/media?parent=15017"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/categories?post=15017"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/tags?post=15017"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}