Velocity Reviews

Velocity Reviews (http://www.velocityreviews.com/forums/index.php)
-   Software (http://www.velocityreviews.com/forums/f6-software.html)
-   -   about sending e-mail in jsp using smtp host (http://www.velocityreviews.com/forums/t743915-about-sending-e-mail-in-jsp-using-smtp-host.html)

Mageshwari.E 02-21-2011 06:43 AM

about sending e-mail in jsp using smtp host
 
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8>
<title>JSP Page</title>
</head>
<body>

<%
String host = "smtp.gmail.com";
int port = 587;
String username = "adkrecruitment@gmail.com";
String password = "anideepskarthi";

Properties props = new Properties();
props.put("mail.smtp.auth", "true");
props.put("mail.smtp.starttls.enable", "true");

Session session1 = Session.getInstance(props);

try {

Message message = new MimeMessage(session1);
message.setFrom(new InternetAddress("adkrecruitment@gmail.com"));
message.setRecipients(Message.RecipientType.TO,
InternetAddress.parse("adkrecruitment@gmail.com")) ;
message.setSubject("Testing Subject");
message.setText("Dear Mail Crawler,\n\n No spam to my email, please!");

Transport transport = session1.getTransport("smtp");
transport.connect(host, port, username, password);

Transport.send(message);

System.out.println("Done");

} catch (MessagingException e) {
throw new RuntimeException(e);
}%>

</body>
</html>



i just receive these type of exception;

type Exception report

message

descriptionThe server encountered an internal error () that prevented it from fulfilling this request.

exception

org.apache.jasper.JasperException: java.lang.RuntimeException: javax.mail.MessagingException: Unknown SMTP host: smtp.gmail.com;
nested exception is:
java.net.UnknownHostException: smtp.gmail.com

can any one solve this and please give the response soon........


All times are GMT. The time now is 09:46 PM.

Powered by vBulletin®. Copyright ©2000 - 2014, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.