Python Will Not Send Email!!

Carsten Haese carsten.haese at gmail.com
Thu Nov 19 12:32:28 EST 2009


Victor Subervi wrote:
> Hi;
> I created this testMail.py file as root:
> 
> #!/usr/bin/env python
> import smtplib
> session = smtplib.SMTP("localhost")
> subject = "Hello, "
> header = "Subject: %s \r\nContent-type: text/html; charset=utf-8\r\n\r\n"
> message = "world!"
> email_from = "victor at is.awesome"
> email_to = ["email at myhost.com <mailto:email at myhost.com>"]
> session.sendmail(email_from, email_to, header+messages)
> 
> [root at 13gems globalsolutionsgroup.vi <http://globalsolutionsgroup.vi>]#
> chmod 755 testMail.py
> [root at 13gems globalsolutionsgroup.vi <http://globalsolutionsgroup.vi>]#
> python testMail.py
> Traceback (most recent call last):
>   File "testMail.py", line 2, in ?
>     import smtplib
>   File "/usr/lib64/python2.4/smtplib.py", line 49, in ?
>     from email.base64MIME import encode as encode_base64
> ImportError: No module named base64MIME
> 
> What gives??

Do you have a file called "email.py" in your current directory or
anywhere else on Python's path outside of the standard library? If so,
it's hiding the real email module from your script and you'll need to
get rid of "your" email.py by renaming or moving it.

--
Carsten Haese
http://informixdb.sourceforge.net




More information about the Python-list mailing list