[x]
Posted via EE Mobile

Search, ask, and monitor your questions on the go with EE Mobile. Visit Experts Exchange from your mobile device and never be out of touch again.

Question
[x]
Attachment Details
[x]
The Solution Rating System

With so many solutions, how can you tell which solutions are most likely to help you and which ones are not? To provide you with a tool to use, we rate our solutions based on various elements that most accurately determine if a solution is a quality solution. To explain what factors affect the solution rating, here are the elements we take into consideration when formulating our solution rating.

  • The Grade of the Solution
  • The Zone Rank of the Expert Providing the Solution
  • The Number of Author and Expert Comments
  • The Number of Experts Contributing
  • The Feedback of the Community

Your Input Matters
Because of the way the system is set up, the most important variable in this equation is you. As a member of Experts Exchange, you are able to cast your vote on the quality of the solutions in regard to how complete, accurate, helpful and easy to understand each solution is. When you provide your feedback, each rating is adjusted accordingly. So, if you see a solution that has a poor rating that you think is a good solution, let us know by rating it. As you do, the rating will be adjusted and will become more accurate for other members of our site.

If you have any suggestions that you would like to make for our rating system, please ask a question in the Suggestions Zone of Community Support.

Thank you!

8.4

JavaMail: javax.mail.AuthenticationFailedException

Asked by grexx in Java Programming Language, Java Server Pages (JSP), JavaMail

Tags: javax.mail.authenticationfailedexception, authenticationfailedexception, mail, javamail, javax.mail

I'm having troubles getting JavaMail to work with authentication, using an outside SMTP-server. The server is not the server of my ISP (the one which connects me to the internet now). I can use this SMTP-server to send mails with Thunderbird, so the connection should work.

I get the following error:

javax.mail.AuthenticationFailedException
      at javax.mail.Service.connect(Service.java:306)
      at javax.mail.Service.connect(Service.java:156)
      at javax.mail.Service.connect(Service.java:105)
      at javax.mail.Transport.send0(Transport.java:168)
      at javax.mail.Transport.send(Transport.java:98)
      at net.grexx.square.mail.SimpleSender.send(SimpleSender.java:66)
      at net.grexx.square.mail.ProcessSqlMail.process(ProcessSqlMail.java:67)
      at org.apache.jsp.SimpleSender.test_002ddb_jsp._jspService(org.apache.jsp.SimpleSender.test_002ddb_jsp:46)
      at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:99)
      at javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
      at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:325)
      at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:295)
      at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:245)
      at javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
      at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:237)
      at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:157)
      at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:214)
      at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:178)
      at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:126)
      at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105)
      at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:107)
      at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148)
      at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:825)
      at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:731)
      at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:526)
      at org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFollowerWorkerThread.java:80)
      at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:684)
      at java.lang.Thread.run(Unknown Source)

The java code that sends the mail is:

      public static void send(String smtpServer, String smtpUsername, String smtpPassword, String to, String from
                  , String subject, String body)
      {
            try
            {
                  Properties props = System.getProperties();
                  // -- Attaching to default Session, or we could start a new one --
                  props.put("mail.smtp.host", smtpServer);
                  props.put("mail.smtp.auth", "true");
                  Session session = Session.getDefaultInstance(props, null);
                  // -- Create a new message --
                  Message msg = new MimeMessage(session);
                  // -- Set the FROM and TO fields --
                  msg.setFrom(new InternetAddress(from));
                  msg.setRecipients(Message.RecipientType.TO,
                  InternetAddress.parse(to, false));
                  // -- We could include CC recipients too --
                  // if (cc != null)
                  // msg.setRecipients(Message.RecipientType.CC
                  // ,InternetAddress.parse(cc, false));
                  // -- Set the subject and body text --
                  msg.setSubject(subject);
                  msg.setText(body);
                  // -- Set some other header information --
                  msg.setHeader("X-Mailer", "GrexxBoxxEmail");
                  msg.setSentDate(new Date());
                  
                  Transport tr = session.getTransport("smtp");
                  tr.connect(smtpServer, smtpUsername, smtpPassword);
                  msg.saveChanges();      // don't forget this
                  
                  // -- Send the message --
                  Transport.send(msg);
                  System.out.println("Message sent OK.");
            }
            catch (Exception ex)
            {
                  ex.printStackTrace();
            }
      }

I have no idea what I'm doing wrong here. Any suggestions?
 
Loading Advertisement...
 
[+][-]01/15/07 04:49 AM, ID: 18315845Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]01/15/07 05:12 AM, ID: 18315927Author Comment

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]01/15/07 06:19 AM, ID: 18316239Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]01/15/07 08:44 AM, ID: 18317281Author Comment

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]01/15/07 08:47 AM, ID: 18317304Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]01/15/07 10:41 AM, ID: 18318087Accepted Solution

View this solution now by starting your 30-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

About this solution

Zones: Java Programming Language, Java Server Pages (JSP), JavaMail
Tags: javax.mail.authenticationfailedexception, authenticationfailedexception, mail, javamail, javax.mail
Sign Up Now!
Solution Provided By: mrcoffee365
Participating Experts: 3
Solution Grade: A
 
[+][-]01/26/07 07:51 AM, ID: 18404967Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
 
Loading Advertisement...
20091021-EE-VQP-81