Created
May 13, 2013 23:40
-
-
Save nathanhere/5572465 to your computer and use it in GitHub Desktop.
Secure method to send emails from Python. Currently only works to send email to self, as more header information is needed for other servers.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from smtplib import SMTP_SSL | |
smtp = SMTP_SSL() | |
def emailUser(): | |
from_who_alias = 'Jarvis' | |
from_who_real = '[email protected]' | |
to = '[email protected]' | |
subject = 'Your Subject' | |
msg = 'Your message' | |
serverOut = 'smtpout.domain.net' | |
port = 465 | |
pw = 'password' | |
content = '''\\\nFrom: {0}\nTo: {1}\nSubject: {2}\n\n\n{3}'''.format(from_who_alias, to, subject, msg) | |
smtp.connect(serverOut, port) | |
smtp.ehlo() | |
smtp.login(from_who_real, pw) | |
smtp.sendmail(from_who_real, to, content) | |
smtp.close() | |
emailUser() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment