Created
January 23, 2015 16:54
-
-
Save jdowner/7dfe2572837dba3e3fac to your computer and use it in GitHub Desktop.
How to send email using python
This file contains hidden or 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
#!/usr/bin/env python | |
import email.mime.text | |
import smtplib | |
username = '[email protected]' | |
password = '****************' | |
hostname = 'outlook.office365.com' | |
msg = email.mime.text.MIMEText('test') | |
msg['Subject'] = 'test' | |
msg['From'] = '[email protected]' | |
msg['To'] = '[email protected]' | |
server = smtplib.SMTP(hostname, 587) | |
server.ehlo() | |
server.starttls() | |
server.ehlo() | |
server.login(username, password) | |
server.sendmail( | |
'[email protected]', | |
['[email protected]'], | |
msg.as_string(), | |
) | |
server.close() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment