2 Replies Latest reply on Jun 15, 2004 12:19 PM by jgkenned

    Trouble send email

    jgkenned

      I am using Jboss 3.2.1 with Tomcat. I'm having an intermittent problem emailing. Here's the error I get:

      javax.mail.SendFailedException: Sending failed;
      nested exception is:
      class javax.mail.MessagingException: Could not connect to SMTP host: smtp-server.tampabay.rr.com, port: 25;
      nested exception is:
      java.net.ConnectException: Connection timed out: connect
      javax.mail.Transport.send0(Transport.java:218)
      javax.mail.Transport.send(Transport.java:80)
      com.je.struts.action.BaseAction.sendMail(BaseAction.java:113)
      com.je.struts.action.BaseAction.sendMail(BaseAction.java:128)

      I only get once in while. In fact the pattern seems to be that the first email is successful and then all emails after this are unsuccessful. I am using Java version 1.4.2_04. Below is the method I use to email:

      public void sendMail(String from, String to,
      String subj, String message) throws Exception
      {
      Context initCtx = new InitialContext();
      Session session = (Session) initCtx.lookup
      ("java:comp/env/mail/arsmail");
      Message mail_message = new MimeMessage(session);
      mail_message.setFrom(new InternetAddress(from));
      InternetAddress tolist[] = new InternetAddress[1];
      tolist[0] = new InternetAddress(to);

      mail_message.setRecipients(Message.RecipientType.TO, tolist);
      mail_message.setSubject(subj);
      mail_message.setContent(message, "text/html");
      Transport.send(mail_message);
      }


      Here is my config:


      java:/ars_mail
      nobody
      password

      <!-- Test -->

      <!-- Change to your mail server prototocol -->



      <!-- Change to the user who will receive mail -->


      <!-- Change to the mail server -->


      <!-- Change to the SMTP gateway server -->


      <!-- Change to the address mail will be from -->


      <!-- Enable debugging output from the javamail classes -->




        • 1. Re: Trouble send email
          jgkenned

          Try again with config:



          java:/ars_mail
          nobody
          password

          <!-- Test -->

          <!-- Change to your mail server prototocol -->



          <!-- Change to the user who will receive mail -->


          <!-- Change to the mail server -->


          <!-- Change to the SMTP gateway server -->


          <!-- Change to the address mail will be from -->


          <!-- Enable debugging output from the javamail classes -->




          • 2. Re: Trouble send email
            jgkenned

            Try again with (3rd time)config:


            <mbean code="org.jboss.mail.MailService"
             name="jboss:service=Mail">
             <attribute name="JNDIName">java:/ars_mail</attribute>
             <attribute name="User">nobody</attribute>
             <attribute name="Password">password</attribute>
             <attribute name="Configuration">
             <!-- Test -->
             <configuration>
             <!-- Change to your mail server prototocol -->
             <property name="mail.store.protocol" value="pop3"/>
             <property name="mail.transport.protocol" value="smtp"/>
            
             <!-- Change to the user who will receive mail -->
             <property name="mail.user" value="nobody"/>
            
             <!-- Change to the mail server -->
             <property name="mail.pop3.host" value="pop-server.tampabay.rr.com"/>
            
             <!-- Change to the SMTP gateway server -->
             <property name="mail.smtp.host" value="smtp-server.tampabay.rr.com"/>
            
             <!-- Change to the address mail will be from -->
             <property name="mail.from" value="nobody@bla.com"/>
            
             <!-- Enable debugging output from the javamail classes -->
             <property name="mail.debug" value="false"/>
             </configuration>
             </attribute>
             </mbean>