{"id":743,"date":"2014-09-23T12:47:38","date_gmt":"2014-09-23T19:47:38","guid":{"rendered":"http:\/\/blog.ls-al.com\/?p=743"},"modified":"2014-09-23T12:47:38","modified_gmt":"2014-09-23T19:47:38","slug":"quick-python-mailer","status":"publish","type":"post","link":"https:\/\/blog.ls-al.com\/quick-python-mailer\/","title":{"rendered":"Quick Python Mailer"},"content":{"rendered":"
\r\nimport sys,smtplib\r\nfrom email.MIMEMultipart import MIMEMultipart\r\nfrom email.MIMEText import MIMEText\r\n\r\nmsg = MIMEMultipart()\r\nmsg['From'] = 'root@domain.ad'\r\nmsg['To'] = 'user@domain.com'\r\nmsg['Subject'] = 'Process finished -' + sys.argv[1]\r\nmessage = 'here is the email'\r\nmsg.attach(MIMEText(message))\r\n\r\nmailserver = smtplib.SMTP('mail.domain.com',25)\r\n# identify ourselves to smtp gmail client\r\nmailserver.ehlo()\r\n# secure our email with tls encryption\r\nmailserver.starttls()\r\n# re-identify ourselves as an encrypted connection\r\nmailserver.ehlo()\r\n\r\nmailserver.sendmail('root@domain.ad','user@domain.com',msg.as_string())\r\n\r\nmailserver.quit()\r\n<\/pre>\n** This script need to be optimized. I am duplicating from and to fields<\/p>\n","protected":false},"excerpt":{"rendered":"
import sys,smtplib from email.MIMEMultipart import MIMEMultipart from email.MIMEText import MIMEText msg = MIMEMultipart() msg[’From’] = ‘root@domain.ad’ msg[’To’] = ‘user@domain.com’ msg[’Subject’]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[13,40],"tags":[],"class_list":["post-743","post","type-post","status-publish","format-standard","hentry","category-python","category-smtp"],"_links":{"self":[{"href":"https:\/\/blog.ls-al.com\/wp-json\/wp\/v2\/posts\/743","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blog.ls-al.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.ls-al.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.ls-al.com\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.ls-al.com\/wp-json\/wp\/v2\/comments?post=743"}],"version-history":[{"count":0,"href":"https:\/\/blog.ls-al.com\/wp-json\/wp\/v2\/posts\/743\/revisions"}],"wp:attachment":[{"href":"https:\/\/blog.ls-al.com\/wp-json\/wp\/v2\/media?parent=743"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.ls-al.com\/wp-json\/wp\/v2\/categories?post=743"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.ls-al.com\/wp-json\/wp\/v2\/tags?post=743"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}