Java Mail : Help plz

Hi ,

I'm trying to send a mail to gmail account using java mail from the servlet.

i set the propertieshost.name=smtp.gmail.com

and havingcode in doPost like

public void doPost(HttpServletRequest req, HttpServletResponse res)

throws ServletException, IOException {

// first, set the "content type" header of the response

res.setContentType("text/html");

// Get the response's PrintWriter to return text to the client.

PrintWriter toClient = res.getWriter();

try {

String toText = req.getParameter("to");

String fromText = req.getParameter("from");

String subjectText = req.getParameter("subject");

String contentText = req.getParameter("content");

SendMessage.send(toText, fromText, subjectText, contentText);

// Respond to client with a confirmation

toClient.println("<html>");

toClient.println("<title>Thank you!</title>");

toClient.println("<body bgcolor=#ffffff>

<img src=images/BEA_Button_Final_web.gif align=right>" +

"<font face=\"Helvetica\">" + "Your message has been sent</font></body>");

toClient.println("</html>");

} catch(Exception e) {

e.printStackTrace();

toClient.println("A problem occured while sending Mail. Here is the exception: " + e);

}

this shows the exception "A problem occured while sending Mail. Here is the exception: javax.mail.MessagingException: Exception reading response; nested exception is: java.net.SocketException: Connection reset "

plz help

thanks in advance

[1634 byte] By [AnjanReddya] at [2007-11-26 13:45:00]
# 1

sorry for the format

i set the mail.host=smtp.gmail.com in weblogic

and my code in doPost like this

public void doPost(HttpServletRequest req, HttpServletResponse res)

throws ServletException, IOException {

// first, set the "content type" header of the response

res.setContentType("text/html");

// Get the response's PrintWriter to return text to the client.

PrintWriter toClient = res.getWriter();

try {

String toText = req.getParameter("to");

String fromText = req.getParameter("from");

String subjectText = req.getParameter("subject");

String contentText = req.getParameter("content");

SendMessage.send(toText, fromText, subjectText, contentText);

// Respond to client with a confirmation

toClient.println("<html>");

toClient.println("<title>Thank you!</title>");

toClient.println("<body bgcolor=#ffffff>

<img

src=images/BEA_Button_Final_web.gif align=right>" +

"<font face=\"Helvetica\">" + "Your message has been sent</font></body>");

toClient.println("</html>");

} catch(Exception e) {

e.printStackTrace();

toClient.println("A problem occured while sending Mail. Here is the

exception: " + e);

}

and i got exception

A problem occured while sending Mail. Here is the exception: javax.mail.MessagingException: Exception reading response; nested exception is: java.net.SocketException: Connection reset " plz help thanks in advance

AnjanReddya at 2007-7-8 1:19:15 > top of Java-index,Enterprise & Remote Computing,Enterprise Technologies...
# 2
http://forum.java.sun.com/post!reply.jspa?messageID=9416331 http://forum.java.sun.com/post!reply.jspa?messageID=9416353you have two posts.. where should I put the answers
G_Abubakra at 2007-7-8 1:19:15 > top of Java-index,Enterprise & Remote Computing,Enterprise Technologies...
# 3
sdd
javasiptecha at 2007-7-8 1:19:15 > top of Java-index,Enterprise & Remote Computing,Enterprise Technologies...