Created
June 25, 2011 07:59
-
-
Save bngsudheer/1046277 to your computer and use it in GitHub Desktop.
Python SMTP Example
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/evn python | |
from smtplib import SMTP | |
from email.MIMEText import MIMEText | |
try: | |
msg = MIMEText("body", "subject is this") | |
msg['Subject']= 'subject is this' | |
msg['From'] = 'sender@example.com' | |
conn = SMTP("mail.example.com") | |
conn.set_debuglevel(False) | |
conn.login('username@example.com', 'password') | |
for to_email in to_emails: | |
conn.sendmail('sender@example.com', 'recipient@example.com', msg.as_string()) | |
conn.close() | |
except Exception, e: | |
print "mail failed; %s" % str(e) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment