Skip to content

Instantly share code, notes, and snippets.

@anir0y
Created January 22, 2020 10:13
Show Gist options
  • Save anir0y/be6d613dd3d793e54f3e6d2be1dd0f65 to your computer and use it in GitHub Desktop.
Save anir0y/be6d613dd3d793e54f3e6d2be1dd0f65 to your computer and use it in GitHub Desktop.
import smtplib
usr = "login@domain.com"
password = "password"
sender = 'you@domain.com'
receivers = ['person@domain.com'] #this needs to be a list
message = """From: From Person <you@domain.com>
To: To Person <to@todomain.com>
Subject: SMTP e-mail test
This is a test e-mail message.
"""
server = smtplib.SMTP('smtp.office365.com', 587) #this is the SMTP for a Microsoft 365 account
server.starttls()
server.login(usr,password)
server.sendmail(sender, receivers, message)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment