4 Replies Latest reply: Dec 4, 2009 3:04 PM by DrClap RSS

    Error implementing Java Mail

      I downloaded the Javamail package extension and placed the mail.jar file in my WEB-INF/lib directory. Then I reloaded the application and did a restart. I am getting the following error message.

      com.sun.mail.smtp.SMTPSendFailedException: 550 bosauthsmtp12: Host No unauthenticated relaying permitted

      Any help would be appreciated.


      Julie Hall
        • 1. Re: Error implementing Java Mail
          That means that you need to authenticate to the SMTP server you're using. Basically that means that you have to "log in" to the server (authenticate) and then it will send mail (relay) for you.
          • 2. Re: Error implementing Java Mail
            You might also want to read the JavaMail FAQ where this problem is specifically discussed (and answered), along with a lot of other problems you may encounter. A side effect of reading through the FAQ is that it helps you understand how Internet mail actually works. A lot of people have unrealistic ideas and expectations about that.

            Google keywords: javamail faq
            • 3. Re: Error implementing Java Mail
              I am still having problems after reading the information. The mail is being called by a jsp program. I've taken most of the code from a book on JSP's. Here is the code inside my jsp file.

              <div id="MainLayer" style="padding-left:10px;padding-right:10px; overflow:hidden; height:100%"> <!-- InstanceBeginEditable name="Main" -->
              <%@ page import="java.util.*" %>
              <%@ page import="java.io.*" %>
              <%@ page import="javax.mail.*" %>
              <%@ page import="javax.mail.internet.*" %>
              <%@ page import="javax.activation.*" %>

              <jsp:useBean id="inn" scope="request" class="bnbTexas.Inn"/>
              <jsp:setProperty name="inn" property="*" />

                   String host="mail.csites2go.com";
                   String to = "bnb@csites2go.com";
                   String from = inn.getEmail();
                   String messageText= "Test of email";
                   boolean sessionDebug=true;
                   Properties props = System.getProperties();
                   props.put("mail.host", host);
                   props.put("mail.transport.protocol", "smtp");
                   Session mailSession= Session.getDefaultInstance(props, null);
                   Message msg = new MimeMessage(mailSession);
                   if (from != null)
                        msg.setFrom(new InternetAddress(from));
                   InternetAddress[] address = {new InternetAddress(to)};
                   msg.setRecipients(Message.RecipientType.TO, address);
                   msg.setSubject("bnb Directory");
                   catch (MessagingException mex) {
                   out.println("mail was sent to " +to);
                   out.println(" from " + from);
                   out.println(" using host " host ".");

              <!-- InstanceEndEditable --></div>

              Do I need to put the username and password in the properties list before getting a session??
              • 4. Re: Error implementing Java Mail
                jules_rocks wrote:
                Do I need to put the username and password in the properties list before getting a session??
                No. First of all there isn't any JavaMail system property which holds a password. Second of all since you have that code in antique 2002-style JSP scriptlets, you should be configuring a mail server into your Java EE container (that's where you put the user ID and password) and getting a mail session via JNDI.