1 Reply Latest reply: Jul 30, 2009 10:58 AM by 661723 RSS

    java mail 500 error how to solve???

    661723
      <%@page contentType="text/html"%>
      <%@page pageEncoding="UTF-8"%>


      <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
      "http://www.w3.org/TR/html4/loose.dtd">
      <html>
      <head>
      <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
      <title>JSP Page</title>
      </head>
      <body>
      <h1>JSP Page</h1>
      <%@ page import="java.util.*, javax.mail.*, javax.mail.internet.*" %>

      <%
      Properties props = new Properties();
      props.put("mail.smtp.starttls.enable","true");
      props.put("mail.host", "smtp.gmail.com");
      props.setProperty("mail.transport.protocol", "smtp");
      //          props.setProperty("mail.host", "smtp.gmail.com");
                props.put("mail.smtps.auth", "false");
                props.put("mail.smtps.port", "465");
                props.put("mail.smtps.socketFactory.port", "465");
                props.put("mail.smtps.socketFactory.class","javax.net.ssl.SSLSocketFactory");
      props.setProperty("mail.smtps.starttl.enable", "true");
                props.put("mail.smtps.socketFactory.fallback", "false");
                props.setProperty("mail.smtps.quitwait", "false");
      System.setProperty("mail.smtps.auth", "true");
      //Session s = Session.getInstance(props,null);
      Session sessions = Session.getInstance(props,
                          new javax.mail.Authenticator()
                {
                     protected PasswordAuthentication getPasswordAuthentication()
                     { return new PasswordAuthentication("art641@gmail.com","mogambo");     }
                });

      InternetAddress from = new InternetAddress("art641@gmail.com");
      InternetAddress to = new InternetAddress("coolsayan.2009@gmail.com");

      MimeMessage message = new MimeMessage(sessions);



      message.setFrom(from);
      message.addRecipient(Message.RecipientType.TO, to);

      message.setSubject("Your subject");
      message.setText("Your text");
      com.sun.mail.smtp.SMTPSSLTransport.send(message);
      //transport.close();

      %>




      </body>
      </html>



      this code is giving error like::


      HTTP Status 500 -

      --------------------------------------------------------------------------------

      type Exception report

      message

      description The server encountered an internal error () that prevented it from fulfilling this request.

      exception

      org.apache.jasper.JasperException: javax.servlet.ServletException: com.sun.mail.smtp.SMTPSendFailedException: 530-5.5.1 Authentication Required. Learn more at
      530 5.5.1 http://mail.google.com/support/bin/answer.py?answer=14257 m34sm4100066waf.60

           org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:522)
           org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:398)
           org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:342)
           org.apache.jasper.servlet.JspServlet.service(JspServlet.java:267)
           javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
           org.netbeans.modules.web.monitor.server.MonitorFilter.doFilter(MonitorFilter.java:390)


      root cause

      javax.servlet.ServletException: com.sun.mail.smtp.SMTPSendFailedException: 530-5.5.1 Authentication Required. Learn more at
      530 5.5.1 http://mail.google.com/support/bin/answer.py?answer=14257 m34sm4100066waf.60

           org.apache.jasper.runtime.PageContextImpl.doHandlePageException(PageContextImpl.java:852)
           org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImpl.java:781)
           org.apache.jsp.mailing_jsp._jspService(mailing_jsp.java:121)
           org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
           javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
           org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:374)
           org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:342)
           org.apache.jasper.servlet.JspServlet.service(JspServlet.java:267)
           javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
           org.netbeans.modules.web.monitor.server.MonitorFilter.doFilter(MonitorFilter.java:390)


      root cause

      com.sun.mail.smtp.SMTPSendFailedException: 530-5.5.1 Authentication Required. Learn more at
      530 5.5.1 http://mail.google.com/support/bin/answer.py?answer=14257 m34sm4100066waf.60

           com.sun.mail.smtp.SMTPTransport.issueSendCommand(SMTPTransport.java:1668)
           com.sun.mail.smtp.SMTPTransport.mailFrom(SMTPTransport.java:1207)
           com.sun.mail.smtp.SMTPTransport.sendMessage(SMTPTransport.java:735)
           javax.mail.Transport.send0(Transport.java:191)
           javax.mail.Transport.send(Transport.java:120)
           org.apache.jsp.mailing_jsp._jspService(mailing_jsp.java:105)
           org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
           javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
           org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:374)
           org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:342)
           org.apache.jasper.servlet.JspServlet.service(JspServlet.java:267)
           javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
           org.netbeans.modules.web.monitor.server.MonitorFilter.doFilter(MonitorFilter.java:390)


      note The full stack trace of the root cause is available in the Apache Tomcat/6.0.18 logs.


      --------------------------------------------------------------------------------

      Apache Tomcat/6.0.18


      any solution????