Created
August 30, 2012 04:35
-
-
Save joujiahe/3522366 to your computer and use it in GitHub Desktop.
Using python SMTP through gmail to send mail with multiple receiver.
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
#!/usr/bin/python | |
import sys | |
import smtplib | |
subject = sys.argv[1] | |
body = sys.argv[2] | |
recipients = sys.argv[3] | |
gmail_user = '[email protected]' | |
gmail_pwd = 'password' | |
smtpserver = smtplib.SMTP("smtp.gmail.com",587) | |
smtpserver.ehlo() | |
smtpserver.starttls() | |
smtpserver.ehlo() | |
smtpserver.login(gmail_user, gmail_pwd) | |
header = 'To:' + recipients + '\n' + 'From: ' + gmail_user + '\n' + 'Subject:' + subject + ' \n' | |
msg = header + '\n' + body + '\n\n' | |
smtpserver.sendmail(gmail_user, recipients.split(', '), msg) | |
smtpserver.close() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment