4 Replies Latest reply on Sep 26, 2006 4:06 PM by ypasmk

    Jboss mail-service.xml localhost, port 25

    ypasmk

      I change the mail-service.xml to

      <server>
      
       <!-- ==================================================================== -->
       <!-- Mail Connection Factory -->
       <!-- ==================================================================== -->
      
       <mbean code="org.jboss.mail.MailService"
       name="jboss:service=Mail">
       <attribute name="JNDIName">java:/Mail</attribute>
       <attribute name="User">some</attribute>
       <attribute name="Password">some1</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="myname@test.com"/>
      
       <!-- Change to the mail server -->
       <property name="mail.pop3.host" value="pop.test.com"/>
      
       <!-- Change to the SMTP gateway server -->
       <property name="mail.smtp.host" value="smtp.test.com"/>
      
       <!-- Change to the address mail will be from -->
       <property name="mail.from" value="me@test.com"/>
      
       <!-- Enable debugging output from the javamail classes -->
       <property name="mail.debug" value="false"/>
       </configuration>
       <depends>jboss:service=Naming</depends>
       </attribute>
       </mbean>
      
      </server>
      


      but when I'm trying to send an email through seam I get the exception


       javax.mail.SendFailedException: Sending failed;
       nested exception is:
       class javax.mail.MessagingException: Could not connect to SMTP host: localhost, port: 25;
       nested exception is:
       java.net.ConnectException: Connection refused
      
      


      the pop3 and smtp server are in a different machine than the machine I'm running the app and in this machine there is no sendmail running. Is this the problem?should I run sendmail to this machine as well?

        • 1. Re: Jboss mail-service.xml localhost, port 25
          tbottger

          Something to check is that you don't have a virus scanner on this machine that is blocking port 25 from mass emails. I ran into this problem on our server and it prevented all emails from going out. Once I disabled this on this server, everything was fine.

          • 2. Re: Jboss mail-service.xml localhost, port 25
            ypasmk

            well the problem seems to be in bounding the mbean. Here is the code for my RegisterMessage

             @Resource(mappedName="java:/Mail")
             Session mailSession;
            
            
            
             public Message UAIMessage(User user) {
            
             try {
            
             Message message = new MimeMessage(getMailSession());
            
             InternetAddress to[] = new InternetAddress[1];
             to[0] = new InternetAddress(user.getEmail());
             message.setRecipients(Message.RecipientType.TO, to);
             message.setSubject("UAI_sys Registration information");
             message.setContent(RegisterContent(user), "text/plain");
             //person.get
             return message;
             }catch(Exception e) { return null; }
            
             }
            


            By debuging this I get that mailSession is always null. When jboss starts I get that mail service is bound to java:/Mail so I can't understand why it's null

            • 3. Re: Jboss mail-service.xml localhost, port 25
              lafr

              Do you still get the error message with localhost ?
              What do oyou get if you execute "nslookup smtp.test.com" on the server running jboss.

              • 4. Re: Jboss mail-service.xml localhost, port 25
                ypasmk

                actually when I'm using

                @Resource(mappedName="java:/Mail")
                

                the mailsession is always null.

                if I use
                 InitialContext ctx = new InitialContext();
                 mailSession=(Session)ctx.lookup("java:/Mail");
                


                everything is fine..so I guess there must be something wrong with this annotation or I really don't know