Skip to content

Instantly share code, notes, and snippets.

@otavio-s-s
Created February 23, 2021 02:05
Show Gist options
  • Save otavio-s-s/3921e3118ae6c5a03a61fe50076b62e8 to your computer and use it in GitHub Desktop.
Save otavio-s-s/3921e3118ae6c5a03a61fe50076b62e8 to your computer and use it in GitHub Desktop.
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