Hi,
I'm trying to configure servlet to send a message to Gmail, but I'm getting waiting for reply message down my browser window.
Here's the servlet code:
import javax.mail.*;
import javax.mail.internet.*;
import javax.servlet.http.*;
import javax.servlet.*;
import java.io.*;
public class JavaMailServlet extends HttpServlet
{
public void doGet(HttpServletRequest request,HttpServletResponse response)
{
try{
String userName=request.getParameter("p1");
String password=request.getParameter("p2");;
Properties props=new Properties();
props.put("mail.smtp.host","smtp.gmail.com");
props.put("mail.smtp.port",465);
Session ses=Session.getInstance(props,null);
Message msg=new MimeMessage(ses);
msg.setFrom(new InternetAddress(request.getRequestURI()));
msg.addRecipient(Message.RecipientType.TO,new InternetAddress("[email protected]"));
msg.setSubject("Hello");
msg.setText("What's up?");
Transport.send(msg);
response.getWriter().println("Message sent");
}
catch(Exception e)
{
System.out.println(e);
}
}
}
What do I've to do to make the connection?