4 Replies Latest reply on Aug 9, 2006 6:26 AM by von dart

    JavaMail in servlet can't find smtp host.

    von dart Newbie

      Following is the code, the error message is "can't find smtp host", but I can receive Mail with my code, who can tell me why?
      public class Servlet1
      extends HttpServlet {
      static class BasicAuthenticator extends Authenticator {
      protected PasswordAuthentication getPasswordAuthentication( ) {

      return new PasswordAuthentication("myname", "mypw");

      private static final String CONTENT_TYPE = "text/html; charset=GBK";
      InitialContext cxt;
      Session sess,sess1;

      public void init() throws ServletException {
      Properties p = System.getProperties();
      p.put("mail.smtp.host", "smtp.126.com");
      cxt=new InitialContext();
      sess= sess1.getInstance(p,new BasicAuthenticator());

      Message msg = new MimeMessage(sess);