Created
February 23, 2021 02:05
-
-
Save otavio-s-s/3921e3118ae6c5a03a61fe50076b62e8 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 send_email(subject, msg, mail_to): | |
try: | |
mail_from = 'email address' | |
password = 'password' | |
mail_to = mail_to | |
server = smtplib.SMTP('smtp.live.com', 587) | |
server.ehlo() | |
server.starttls() | |
server.login(mail_from, password) | |
message = f'Subject: {subject}\n\n{msg}' | |
server.sendmail(mail_from, mail_to, message) | |
server.quit() | |
print('Email successfully sent!') | |
except: | |
print('Failed to send email.') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment