Last active
February 8, 2016 18:07
-
-
Save makerj/ed2eb9a9efeb8cae2557 to your computer and use it in GitHub Desktop.
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
def sendmail(recipients, anime, content): | |
""" | |
Send email to recipients | |
:param recipients: recipients | |
:param anime: animation info | |
:param content: io.StringIO object messages | |
:return: None | |
""" | |
if 1 == 1: # TODO Remove this dev option | |
return | |
mail = MIMEText(content.getvalue()) | |
mail['Subject'] = '%s episode %d is uploaded!' % (anime.title, anime.latest_episode) | |
mailserver = smtplib.SMTP(settings.smtp_addr, settings.smtp_port) | |
mailserver.sendmail(settings.mail_username, settings.recipients, mail.as_string()) | |
mailserver.quit() | |
# # SMTP_SSL Example | |
# server_ssl = smtplib.SMTP_SSL(settings.email_server_addr, settings.email_server_port) | |
# server_ssl.ehlo() # optional, called by login() | |
# server_ssl.login(settings.email_username, settings.email_password) | |
# # ssl server doesn't support or need tls, so don't call server_ssl.starttls() | |
# server_ssl.sendmail('ohenwkgdj@gmail.com', recipients, mail.as_string()) | |
# # server_ssl.quit() | |
# server_ssl.close() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment