about sending e-mail in jsp using smtp host

Discussion in 'Software' started by Mageshwari.E, Feb 21, 2011.

  1. Mageshwari.E

    Mageshwari.E

    Joined:
    Feb 21, 2011
    Messages:
    1
    <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........
    Mageshwari.E, Feb 21, 2011
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Andre Vaux

    SMTP proxy to another Internet host

    Andre Vaux, Jul 19, 2004, in forum: Cisco
    Replies:
    1
    Views:
    850
    Alan Strassberg
    Jul 19, 2004
  2. *** HAWK

    Host Name of Hotmail SMTP Server

    *** HAWK, Jul 12, 2003, in forum: Computer Support
    Replies:
    1
    Views:
    25,586
    Ava Keech
    Jul 12, 2003
  3. °Mike°

    Re: Error : The host 'SMTP' could not be found

    °Mike°, Aug 14, 2003, in forum: Computer Support
    Replies:
    0
    Views:
    449
    °Mike°
    Aug 14, 2003
  4. vijendra
    Replies:
    1
    Views:
    7,858
    arpit1988
    Oct 6, 2006
  5. Dany P. Wu

    Using local SMTP host on a laptop

    Dany P. Wu, Jan 21, 2004, in forum: NZ Computing
    Replies:
    9
    Views:
    1,507
    Enkidu
    Jan 23, 2004
Loading...

Share This Page