Martin MOKREJŠ
mmokrejs at ribosome.natur.cuni.cz
Tue Jul 26 15:46:12 EDT 2005
Hi Joshua, Joshua Cohen wrote: > Hi Everyone, > > I have been attempting to make use of the SMTPlib using the following code: > > import smtplib from email.MIMEText import MIMEText > 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 = MIMEText("Dear colleague") msg['Subject'] = "THIS IS A TEST" msg['From'] = si.site_email msg['To'] = _email try: # send mail server = smtplib.SMTP(MyServer) server.sendmail(msg['From'], msg['To'], msg.as_string()) server.quit() except Exception, e: dbhandler.rollback(raise_exception = 0) error += "Error while sending confirmation email to '" + msg['To'] + "' via SMTP server '" + MyServer + str(e) > 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
|