How to send email from a Python script
Today I needed to send email from a Python script. As always I searched Google and found the following script that fits to my need. import smtplib SERVER = "localhost" FROM = "sender@example.com" TO = ["user@example.com"] # must be a list SUBJECT = "Hello!" TEXT = "This message was sent with Python's smtplib." # Prepare actual message message = """\ From: %s To: %s Subject: %s %s """ % (FROM, ", ".join(TO), SUBJECT, TEXT) # Send the mail server = smtplib.SMTP(SERVER) server.sendmail(FROM, TO, message) server.quit() [Source: http://effbot.org/pyfaq/how-do-i-send-mail-from-a-python-script.htm] But when I tried to run the program, I got the following error message: Traceback (most recent call last):
File "email.py", line 1, in
import smtplib
File "/usr/lib/python2.5/smtplib.py", line 46, in
import email.Utils
File "/home/dsebd/email....