rerouting content to email a/c using jsp
1 posts in topic
Flat View  Flat View

Posted By:   shankar_k
Posted On:   Thursday, March 29, 2001 11:09 PM

The client fills a order form & posts the same to my webserver which should reroute to my pop3 mail account. so settings required on the webserver and how do i reroute the form contents to the mail via the webserver.

Re: rerouting content to email a/c using jsp

Posted By:   Selena_Leary  
Posted On:   Thursday, May 24, 2001 07:59 AM

Install the JavaMail API (http://www.javasoft.com/products/javamail/index.html) and then send your form results to a bean or servlet. A basic mail bean (one sender, one recipient) would look like this:

import java.util.*;

import java.io.*;

import java.beans.*;

import javax.mail.*;

import javax.mail.internet.*;

public class sendmail implements Serializable{

private String from;

private String to;

private String subject = "[no subject]";

private String content = " ";

private String type = "text/plain";

private String mailserver = "smtp.server.com";

private String username = "username";

private String passcode = "passcode";

private boolean email;

public void setFrom(String f){

from = f;


public void setTo(String tt){

to = tt;


public void setSubject(String sub){

subject = sub;


public void setContent(String c){

content = c;


public void setType(String t){

type = t;


public void setMailserver(String ms){

mailserver = ms;


public void setUsername(String u){

username = u;


public void setPasscode(String p){

passcode = p;


public sendmail(){}

public boolean getEmail(){

Properties props = new Properties();

Session s = Session.getInstance(props, null);

MimeMessage m = new MimeMessage(s);


//set message body

m.setContent(content, type);

//set message subject


//set FROM
innerfrom = new InternetAddress(from);


//set TO
Address innerto = new InternetAddress(to);

m.addRecipient(Message.RecipientType.TO, innerto);

Transport t = s.getTransport("smtp");

t.connect(mailserver, username, passcode);

t.sendMessage(m, m.getAllRecipients());


return true;


catch(MessagingException me){

//catch code

return false;



About | Sitemap | Contact