How to use python or mod_python file to handle HTML form?

Nancy wxling3 at
Wed Jul 28 04:13:31 CEST 2004

Hi, Guys,
   I am new to Python. I am trying to following the example on  
   In this example, it gives the following html code,
    <form action="" method="POST">
      Name:    <input type="text" name="name"><br>
      Email:   <input type="text" name="email"><br>
      Comment: <textarea name="comment" rows=4 cols=20></textarea><br>
      <input type="submit">
import smtplib
WEBMASTER = "webmaster"   # webmaster e-mail
SMTP_SERVER = "localhost" # your SMTP server
def email(req, name, email, comment):
        if not (name and email and comment):
        return "A required parameter is missing, \
               please go back and correct the error"
     msg = """\
From: %s
Subject: feedback
To: %s
I have the following comment:
Thank You,
""" % (email, WEBMASTER, comment, name)
    conn = smtplib.SMTP(SMTP_SERVER)
    conn.sendmail(email, [WEBMASTER], msg)
    # provide feedback to the user
    s = """\
Dear %s,<br>
Thank You for your kind comments, we
will get back to you shortly.
</html>""" % name
    return s
  My environment is
  1) Apache 2.0 server runs on WinXP Pro using 8080 port (IIS runs at
same time on 80 port)
  2) I don't have any permission to access any SMTP server.
  3) I don't want to install any SMTP server on my PC.
  Now the question is,
  I cann't run above example code since I don't have SMTP server on my
PC. How can I use my to handle HTML form?
   Thanks a lot.


More information about the Python-list mailing list