Hi,
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 = "
[email protected]"
TO = ["
[email protected]"] # 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()
But when I tried to run the program, I got the following error message:
Traceback (most recent call last):
File "C:/Python26/email.py", line 1, in <module>
import smtplib
File "C:\Python26\lib\smtplib.py", line 46, in <module>
import email.utils
File "C:/Python26/email.py", line 24, in <module>
server = smtplib.SMTP(SERVER)
AttributeError: 'module' object has no attribute 'SMTP'
How can i solve this problem? Any one can help me?
Thanks in advance,
Nimmy.