• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Error in sending mail through JSP using (SmtpClient)

 
Rinku Sharma
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi friends,
I am trying to develop a FormMailer application using Servlets or JSP. I tried the thing by using the code mentioned below, but i am getting an error " sun.net.smtp:Sun.ProtocolException 550 5.7.7. Unable to relay to amits_007@rediffmail.com" on the DOS prompt and my browser screen doesnt show anything.I am using TOMCAT as the server and JSP as the front end.
CODE follows:
<%@ page language="java" import="sun.net.smtp.SmtpClient, java.io.*" %>
<% String from="amits_007@hotmail.com";
String to="amits_007@rediffmail.com";
try{ SmtpClient client = new SmtpClient("mail.yahoo.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("Cool beans! :-)");
message.println();
message.println("Govind Seshadri");
message.println("jGuru.com");
message.println();
client.closeServer();
out.println("amirr");
}
catch (IOException e){ System.out.println("ERROR SENDING EMAIL:"+e); }%>

Kindly help me out with this. Please suggest if there is any other way by which this applicatin can be made.
Bye,
Amit
 
Phil Hanna
Ranch Hand
Posts: 118
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
mail.yahoo.com is not an SMTP mail host. It is the URL of a proprietary Web-based mail system. You do not have direct access to its outgoing mail capabilities with SMTP.
------------------
Phil Hanna
Author of :
JSP: The Complete Reference
Instant Java Servlets
 
Don't get me started about those stupid light bulbs.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic