<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 = "";
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(""));
message.setRecipients(Message.RecipientType.TO,
InternetAddress.parse("")) ;
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........
|