home *** CD-ROM | disk | FTP | other *** search
/ PC Online 1999 November / PCONLINE_11_99.ISO / filesbbs / OS2 / APCHSSL2.ZIP / OS2HTTPD / public / htdocs / gsp / form2mail.gsp < prev    next >
Encoding:
Text File  |  1999-02-01  |  1.0 KB  |  45 lines

  1. <html>
  2.  <head><title>Form2Mail in GSP</title></head>
  3.  <body bgcolor="#ffffff">
  4.  
  5.  <h1>Form2Mail in GSP</h1>
  6.  
  7.   <java type="import">com.bitmechanic.smtp.*</java>
  8.   <java>
  9.     Form form = request.getForm();
  10.     if(form.getValue("submit") != null) {
  11.       // Send the mail
  12.       Mailer mailer = application.getMailer();
  13.       mailer.send(new MailMessage("recipient@yourdomain.com",
  14.                                   form.getValue("from", false),
  15.                                   "Web form submission",
  16.                                   form.getValue("body", false)));
  17.   </java>
  18.  
  19.      <strong>Mail sent.</strong>  Thanks for your comments.
  20.  
  21.   <java>
  22.     }
  23.     else {
  24.   </java>
  25.  
  26.      <form method="post" action="form2mail.gsp">
  27.      
  28.      Your email address: `form.getTextfield("from", 20, 50)`
  29.      <br>
  30.      Your comments:
  31.      <br>
  32.      `form.getTextarea("body", 5, 40)`
  33.      
  34.      <p>
  35.      <input type="submit" name="submit" value="Submit Comments">
  36.      <input type="reset">
  37.      </form>
  38.  
  39.   <java>
  40.     }
  41.   </java>
  42.  
  43. </body>
  44. </html>
  45.