Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > General Computer Discussion > Software > about sending e-mail in jsp using smtp host

Reply
Thread Tools

about sending e-mail in jsp using smtp host

 
 
Mageshwari.E Mageshwari.E is offline
Junior Member
Join Date: Feb 2011
Posts: 1
 
      02-21-2011
<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 = "(E-Mail Removed)";
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("(E-Mail Removed)"));
message.setRecipients(Message.RecipientType.TO,
InternetAddress.parse("(E-Mail Removed)")) ;
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........
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Finding SMTP host and port knowing the e-mail address using JAVA API Andreea Java 0 04-21-2012 07:12 PM
Sending SMTP mail when SMTP server is unavailable matthewjbarr@gmail.com Java 3 01-24-2006 06:53 PM
sending of mail (smtp) - connection refused - but smtp server isrunning! Alex Hunsley Python 4 06-29-2004 04:30 PM
RE: sending of mail (smtp) - connection refused - but smtp serveris running! Raaijmakers, Vincent \(GE Infrastructure\) Python 0 06-29-2004 02:38 PM
Using local SMTP host on a laptop Dany P. Wu NZ Computing 9 01-23-2004 09:39 AM



Advertisments