Created
January 31, 2019 09:50
-
-
Save dasgoll/2f27ec2b703fbcb49a273d550d7865f8 to your computer and use it in GitHub Desktop.
Python send smtp email outlook
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
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