[mod_python] SMTPLIB

Joshua Cohen JoshC at usracmfg.com
Tue Jul 26 12:57:02 EDT 2005


Hi Everyone, 

I have been attempting to make use of the SMTPlib using the following code:

import smtplib
from mod_python import apache 

def maile(req):
    sys.stdout = req
    req.content_type = "text/html" 
    
    fromaddr = "b at b.com"
    toaddrs  = "c at c.com"
    # Add the From: and To: headers at the start!
    msg = ("From: %s\r\nTo: %s\r\n\r\n"
           % (fromaddr, ", ".join(toaddrs)))
    msg = msg + "THIS IS A TEST"
    
    server = smtplib.SMTP('MyServer')
    server.set_debuglevel(1)
    server.sendmail(fromaddr, toaddrs, msg)
    server.quit()

However when I execute the program, I receive the following error:

Mod_python error: "PythonHandler mod_python.publisher"
Traceback (most recent call last):
  File "/usr/lib/python2.4/site-packages/mod_python/apache.py", line 299, in HandlerDispatch
    result = object(req)
  File "/usr/lib/python2.4/site-packages/mod_python/publisher.py", line 98, in handler
    path=[path])
  File "/usr/lib/python2.4/site-packages/mod_python/apache.py", line 457, in import_module
    module = imp.load_module(mname, f, p, d)
  File "/var/www/html/reports/mail.py", line 1, in ?
    import smtplib
  File "/usr/lib/python2.4/smtplib.py", line 49, in ?
    from email.base64MIME import encode as encode_base64
ImportError: No module named base64MIME

************************************************************************
This module does infact exist and I am able to import it via the command line. Any ideas? 

I am running Fedora Core 4 w/Apache 2, Python 2.4.1, and Mod_Python

Thanks, 
Josh



More information about the Mod_python mailing list