You should be able to do this fairly simply by using socket to port 25 and
take SMTP RFC to talk to SMTP server.

Some sample codes shown below (for servlet but should be used OK with JSP)
should help you a bit.

Steve
--
KBMail Software & Java Hosting Services Provider
Web site: http://kbmail.com  |  http://www.ebpcs.net

----------------------------------------------------

    try {
      Socket sk = new Socket(SMTP_Server, SMTP_Port);
      out =  sk.getOutputStream();
      back=  new BufferedReader(new
InputStreamReader(sk.getInputStream()));;
    }
    catch (Exception E) {
      System.out.println("Error during opening socket to SMTP server:
"+E.getMessage());
      return;
    }

    // Negotiation with SMTP server
    String ToSend;
    String Result;
    try {
      // Check server ready ...
      Result=back.readLine();
      if (!Result.substring(0, 3).equalsIgnoreCase("220"))
        throw new Exception("Server error: "+Result);
      // Initializing ...
      ToSend="HELO formMail";
      utils.sendLine(out, ToSend);
      Result=back.readLine();
      if (!Result.substring(0, 3).equalsIgnoreCase("250"))
        throw new Exception("Server error: "+Result);
      // Set sender
      ToSend="MAIL FROM:<"+from_Mail+">";
      utils.sendLine(out, ToSend);
      Result=back.readLine();
      if (!Result.substring(0, 3).equalsIgnoreCase("250"))
        throw new Exception("Server error: "+Result);
      // Set recipient
      ToSend="RCPT TO:<"+to_Mail+">";
      utils.sendLine(out, ToSend);
      Result=back.readLine();
      if (!Result.substring(0, 3).equalsIgnoreCase("250"))
        throw new Exception("Server error: "+Result);
      // Set additional recipient(s)
      if (!to_More.equals("")) {
        StringTokenizer sendMore = new StringTokenizer(to_More, ";");
        while (sendMore.hasMoreTokens()) {
          ToSend="RCPT TO:<"+sendMore.nextToken()+">";
          utils.sendLine(out, ToSend);
          Result=back.readLine();
          if (!Result.substring(0, 3).equalsIgnoreCase("250"))
            throw new Exception("Server error: "+Result);
        }
      }
      // Set data stream ready
      ToSend="DATA";
      utils.sendLine(out, ToSend);
      Result=back.readLine();
      if (!Result.substring(0, 3).equalsIgnoreCase("354"))
        throw new Exception("Server error: "+Result);
    }
    catch (Exception E) {
      System.out.println("Error during negotiating with SMTP
server:"+E.getMessage());
      return;
    }

----- Original Message -----
From: Mathew Olsen GCS <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Friday, January 07, 2000 1:27 AM
Subject: mail form


> I am looking for jsp code that will take input from a form and send that
> input to a specified e-mail account.
>
> Has anyone done this before?
>
> Previously I have done a lot of work with Cold Fusion and I know Cold
Fusion
> has code to do this, but I was wondering if anyone knew how to do this
with
> jsp's.
>
> I'm not looking for a JavaScript that opens up an e-mail application, I
want
> to hard code it into my code.
>
>
===========================================================================
> To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff
JSP-INTEREST".
> FAQs on JSP can be found at:
>  http://java.sun.com/products/jsp/faq.html
>  http://www.esperanto.org.nz/jsp/jspfaq.html

===========================================================================
To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff JSP-INTEREST".
FAQs on JSP can be found at:
 http://java.sun.com/products/jsp/faq.html
 http://www.esperanto.org.nz/jsp/jspfaq.html

Reply via email to