Code is not working
1 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   Nilesh_Ghadigaonkar
Posted On:   Tuesday, April 4, 2006 01:40 AM

I am doing a project in which i want to send a mail using jsp.I tried the folloing code given on site of Jguru under title sending mail using jsp <%@ page import="sun.net.smtp.SmtpClient, java.io.*" %> <% String from="gseshad@hotmail.com"; String to="gov@jguru.com, govi@bigfoot.com"; try{ SmtpClient client = new SmtpClient("mail.xxxxx.xxx"); 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!"   More>>


I am doing a project in which i want to send a mail using jsp.I tried the folloing code given on site of Jguru under title sending mail using jsp




<%@ page import="sun.net.smtp.SmtpClient, java.io.*" %>
<%
String from="gseshad@hotmail.com";


String to="gov@jguru.com, govi@bigfoot.com";

try{
SmtpClient client = new SmtpClient("mail.xxxxx.xxx");
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("Cool beans! :-)");
message.println();
message.println();
client.closeServer();
}
catch (IOException e){
System.out.println("ERROR SENDING EMAIL:"+e);
}
%>


This gives error after client.from(from) line stating client can not be access this way



We had tried the java code which worked properly,but after incuding userid and password.(server do not allow to post mail directly.


I want to know how can i put userid and password in above jsp code



Thanks.    <<Less

Re: Code is not working

Posted By:   WarnerJan_Veldhuis  
Posted On:   Tuesday, April 4, 2006 04:00 AM

Using a Session, you use an Authenticator. (See here. But you are using sun specific classes, so I have no idea how to use those... Nobody would know... Try to steer clear of packages from sun.* and com.sun.*. It's Sun only, and it will change whenever Sun feels like it. I also doubt there is documentation with that. Use the regular JavaMail packages (javax.mail.*)
About | Sitemap | Contact