how to send a form html by email ?

Gerard Breiner gerard.breiner at ias.u-psud.fr
Mon Mar 17 06:48:51 EST 2003


My form is a html form. My server apache is configured with mod-python and
here is a part of my http.conf :
------------------------------
Alias /python "C:/Program Files/Apache Group/Apache/htdocs/python"
     <Directory "C:/Program Files/Apache Group/Apache/htdocs/python">
  AddHandler python-program .py
  PythonHandler email
  PythonDebug on
     </Directory>
---------------------------------
and here is my email.py file that i am trying to test.
--------------------------------
import smtplib

# Import the email modules we'll need
from email.MIMEText import MIMEText

# Open a plain text file for reading.  For this example, assume that
# the text file contains only ASCII characters.
fp = open(textfile, 'rb')
# Create a text/plain message
msg = MIMEText(fp.read())
fp.close()

# me == the sender's email address
# you == the recipient's email address
msg['Subject'] = 'The contents of %s' % textfile
msg['From'] = me
msg['To'] = you

# Send the message via our own SMTP server, but don't include the
# envelope header.
s = smtplib.SMTP()
s.connect()
s.sendmail(me, [you], msg.as_string())
s.close()
-------------------------------------------

Here is the error from my navigator :
Mod_python error: "PythonHandler email"

--------------------------------
Traceback (most recent call last):

  File "C:\Python22\Lib\mod_python\apache.py", line 181, in Dispatch
    module = import_module(module_name, _req)

  File "C:\Python22\Lib\mod_python\apache.py", line 335, in import_module
    module = imp.load_module(mname, f, p, d)

  File "c:/program files/apache group/apache/htdocs/python\email.py", line
2, in ?

ImportError: No module named MIMEText
---------------------------
Maybe, this module isn't implemented in apache module ?

Best regards

gerard

"Gerhard Häring" <gerhard.haering at opus-gmbh.net> a écrit dans le message de
news: slrnb7ba24.1fo.gerhard.haering at haering.opus-gmbh.net...
> Gerard Breiner <gerard.breiner at ias.u-psud.fr> wrote:
> > Hello,
> >
> > Is someone has already made a script python so that to send a form by
> > email from the web server ? [...]
>
> You can send email using the smtplib module. I'm not sure what kind of
> "form" you might want to send by email, though.
>
> -- Gerhard






More information about the Python-list mailing list