sending an email through jsp

is there any facility to send an email to persons through jsp
[75 byte] By [dhiraja] at [2007-9-26 3:05:09]
# 1
visit www.jspinsider.com
govindarajanp at 2007-6-29 11:06:38 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 2

Hi dhiraja,

Here iam giving you the related code. I hope this will help you out.

%@ page import="sun.net.smtp.SmtpClient, java.io.*" %>

<%

String from="xyzabc@rediffmail.com";

String to="abc@sun.com, hi@yahoo.com";

try{

SmtpClient client = new SmtpClient("mail.1234.com");

client.from(from);

client.to(to);

PrintStream message = client.startMessage();

message.println("To: " + to);

message.println("Subject: Sending email from JSP");

message.println("This was sent from a JSP page");

message.println();

message.println(" be Cool ");

message.println();

message.println("xyzabc");

message.println("sun.com");

message.println();

client.closeServer();

}

catch (IOException e){

System.out.println("error sending email:"+e);

}

%>

Regards,

Tirumalarao

Developer Technical Support,

Sun Microsystems,India.

rao_indts at 2007-6-29 11:06:38 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 3
Yes, javamail will let you do that. You need to download the JavaMail APi from this site, but it works fine.
Breakfast at 2007-6-29 11:06:38 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...