Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    New Coder
    Join Date
    Jul 2008
    Posts
    57
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Sending mails through jsp

    Hi,

    I want to send an mail using JSP.

    I have a code like that

    [jsp]
    <%@ page import="sun.net.smtp.SmtpClient, java.io.*" %>
    <%
    String from="eminosoft.sravani@gmail.com";
    String to="eminosoft.sravani@gmail.com";
    try{
    SmtpClient client = new SmtpClient("localhost");
    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();
    client.closeServer();
    }
    catch (IOException e){
    System.out.println("ERROR SENDING EMAIL:"+e);
    }
    %>
    [/jsp]

    It runs without any error and also didn't receive the mails .

    plz tell that whats the problem in my code.

  • #2
    Senior Coder shyam's Avatar
    Join Date
    Jul 2005
    Posts
    1,563
    Thanks
    2
    Thanked 163 Times in 160 Posts
    no errors? not even in the console?
    You never have to change anything you got up in the middle of the night to write. -- Saul Bellow


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •