{"id":64209,"date":"2016-04-15T09:49:05","date_gmt":"2016-04-15T17:49:05","guid":{"rendered":"http:\/\/www.transterrestrial.com\/?p=64209"},"modified":"2016-04-15T14:55:38","modified_gmt":"2016-04-15T22:55:38","slug":"email-issue","status":"publish","type":"post","link":"https:\/\/www.transterrestrial.com\/wordpress\/2016\/04\/15\/email-issue\/","title":{"rendered":"Email Issue"},"content":{"rendered":"<p>I&#8217;m trying to send myself email from my own Linux machine, via SMPT. I&#8217;ve written the following Python program:<\/p>\n<blockquote><p>#!\/usr\/bin\/env python3<\/p>\n<p># Import smtplib for the actual sending function<br \/>\nimport smtplib<\/p>\n<p># Import the email modules we&#8217;ll need<br \/>\nfrom email.mime.text import MIMEText<\/p>\n<p># Open a plain text file for reading.  For this example, assume that<br \/>\n# the text file contains only ASCII characters.<br \/>\nwith open(&#8220;test.txt&#8221;) as fp:<br \/>\n    # Create a text\/plain message<br \/>\n  msg = MIMEText(fp.read())<\/p>\n<p># me == the sender&#8217;s email address<br \/>\n# you == the recipient&#8217;s email address<br \/>\nmsg[&#8216;Subject&#8217;] = &#8220;Test&#8221;<br \/>\nmsg[&#8216;From&#8217;] = &#8220;simberg@interglobal.org&#8221;<br \/>\nmsg[&#8216;To&#8217;] = &#8220;simberg@interglobal.org&#8221;<\/p>\n<p># Send the message via our own SMTP server.<br \/>\ns = smtplib.SMTP(&#8216;localhost&#8217;)<br \/>\nprint(&#8220;s has been opened&#8221;)<br \/>\ns.send_message(msg)<br \/>\nprint(&#8220;after send_message&#8221;)<br \/>\ns.quit()<br \/>\nprint(&#8220;End script&#8221;)<\/p><\/blockquote>\n<p>It runs with no errors, prints the statements to the terminal, but no email appears. How do I diagnose this?<\/p>\n<p>[Update a while later]<\/p>\n<p>Thanks for the help in comments. Still haven&#8217;t solved it, but the need for the application that I needed it for has gone away. Nonetheless, it would be good in general to know how to email from a Python script.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>I&#8217;m trying to send myself email from my own Linux machine, via SMPT. I&#8217;ve written the following Python program: #!\/usr\/bin\/env python3 # Import smtplib for the actual sending function import smtplib # Import the email modules we&#8217;ll need from email.mime.text import MIMEText # Open a plain text file for reading. For this example, assume that &hellip; <a href=\"https:\/\/www.transterrestrial.com\/wordpress\/2016\/04\/15\/email-issue\/\" class=\"more-link\">Continue reading <span class=\"screen-reader-text\">Email Issue<\/span> <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[16,27,3],"tags":[],"class_list":["post-64209","post","type-post","status-publish","format-standard","hentry","category-administrative","category-mathematics","category-technology-and-society"],"_links":{"self":[{"href":"https:\/\/www.transterrestrial.com\/wordpress\/wp-json\/wp\/v2\/posts\/64209","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.transterrestrial.com\/wordpress\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.transterrestrial.com\/wordpress\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.transterrestrial.com\/wordpress\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.transterrestrial.com\/wordpress\/wp-json\/wp\/v2\/comments?post=64209"}],"version-history":[{"count":3,"href":"https:\/\/www.transterrestrial.com\/wordpress\/wp-json\/wp\/v2\/posts\/64209\/revisions"}],"predecessor-version":[{"id":64215,"href":"https:\/\/www.transterrestrial.com\/wordpress\/wp-json\/wp\/v2\/posts\/64209\/revisions\/64215"}],"wp:attachment":[{"href":"https:\/\/www.transterrestrial.com\/wordpress\/wp-json\/wp\/v2\/media?parent=64209"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.transterrestrial.com\/wordpress\/wp-json\/wp\/v2\/categories?post=64209"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.transterrestrial.com\/wordpress\/wp-json\/wp\/v2\/tags?post=64209"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}