Skip to content

Instantly share code, notes, and snippets.

@dasgoll
Created January 31, 2019 09:50
Show Gist options
  • Save dasgoll/2f27ec2b703fbcb49a273d550d7865f8 to your computer and use it in GitHub Desktop.
Save dasgoll/2f27ec2b703fbcb49a273d550d7865f8 to your computer and use it in GitHub Desktop.
Python send smtp email outlook
https://medium.freecodecamp.org/send-emails-using-code-4fcea9df63f
# import the smtplib module. It should be included in Python by default
import smtplib
# set up the SMTP server
s = smtplib.SMTP(host='smtp-mail.outlook.com', port=587)
s.starttls()
s.login('[email protected]', 'password')
===
import smtplib
import time
server = smtplib.SMTP_SSL('host', port)
server.ehlo()
server.login("myemail", "password")
server.ehlo()
print ('server working fine')
time.sleep(5)
sender = "myemail@......."
receivers = ["myemail@......"]
subject = "SMTP e-mail Test"
msg = "This is an automated message being sent by Python. Python is the mastermind behind this."
server.sendmail(sender, receivers, subject, msg)
print ('sending email to outlook')
server.quit()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment