Created
September 23, 2015 02:22
-
-
Save tklee1975/06571058ef76105ad2e2 to your computer and use it in GitHub Desktop.
Python: Send email by SMTP
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/python | |
| import smtplib | |
| gmail_user = "sender@gmail.com" | |
| gmail_pwd = "sender_password" | |
| def send_email(msg, gmail_user, gmail_pwd, to_list): | |
| mailServer = smtplib.SMTP("smtp.gmail.com", 587) | |
| mailServer.ehlo() | |
| mailServer.starttls() | |
| mailServer.ehlo() | |
| mailServer.login(gmail_user, gmail_pwd) | |
| mailServer.sendmail(gmail_user, to_list, msg) | |
| mailServer.quit() | |
| def main(): | |
| send_email("Hello everybody", gmail_user, gmail_pwd, ["receiver@gmail.com"]) | |
| if __name__ == '__main__': | |
| main() | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment