1 2 Previous Next 27 Replies Latest reply on Jun 20, 2012 8:26 AM by ctomc Go to original post
      • 15. Re: JavaMail support on AS7
        zenzei2k

        Hi tomaz! Thanks for your clarification.

         

        About the starttls, I think i need it cause I'm using gmail smtp and it requires that property to be set (at least on jboss4). I didn't need it so quickly cause I'm testing Jboss 7 right now, but I'll glad to test the fix when you prepare it.

         

        Thanks in advance!

        • 16. Re: JavaMail support on AS7
          alfred.graber

          Hi Tomaz

           

          unfortunately it seems, that your implementation does not work yet 100%

           

          logging:

           

          Setting the attribute "debug" has no effect.

          The reason is that the Properties-object used to create the new Session instance contains the property "mail.debug" but as a Boolean.

          This is wrong: Properties must only contain String values, otherwise the method "getProperty" will return null (everything except Strings is just ignored).

          I have seen, that you use the "put" method to set the properties - you should not do this, because the "put" method is inherited from Hashtable and allowes to set any object as value - use the "setProperty" method instead

           

           

          smtp-auth:

           

          it seems that corresponding property "mail.smtp.auth" is not set (I did not find it) - or maybe its the same problem as above (Boolean istead of String) - so there is no authentication performed before sending the mail, which leads to exception if the mailserver requires authentication.

           

          Cheers

           

          Alfred

          • 17. Re: JavaMail support on AS7
            ctomc

            Hi guys,

             

            @Alfred tnx for info, it helped alot.

             

            I have fixed the problem of logging not working  and improved it furher so it also sets protocol to debug not just general java mail stuff.

            Implementation now correctly honors authentification and also correctly handles SSL encripted connections.

            I have tested with gmail SSL smtp and it worked correctly, but with TLS(different port) I get strage exception that I will have to digg in deeper.

             

            config with which I have tested:

             

            <mail-session jndi-name="java:/Mail" debug="true">

              <smtp-server ssl="true" outbound-socket-binding-ref="mail-smtp">                   

                 <login name="user dot name at  gmail dot com" password="password"/>

              </smtp-server>               

            </mail-session>

             

            ...

            ...

            <outbound-socket-binding name="mail-smtp">

                <remote-destination host="smtp.gmail.com" port="465"/>  <--! please note 465 is SSL that works, 587 is TLS and currently does not work  -->

            </outbound-socket-binding>

             

            fixes are currently present in my work of as7 https://github.com/ctomc/jboss-as/tree/mail2

            If possible can you test the fixes if they work for your scenarios.

             

            Tnx,

            Tomaz

            • 18. Re: JavaMail support on AS7
              whutchinson

              Hi,

               

              Was not able to get authentication to work after trying with the latest hudson build. Perhaps you have it resolved already, but I had to modify MailSessionService with the changes below.

              Apologies for the lack of detail, this was my last obstacle for the upgrade from version 5 to 7.1 and took a little while to figure out the issue.

               

               


              <mail-session jndi-name="java:/Mail" debug="true">

              <smtp-server outbound-socket-binding-ref="mail-smtp-pbrfid">

              <login name="xxxxxxx" password="xxxxx"/>

              </smtp-server>

              </mail-session>

               

               


              <outbound-socket-binding name="mail-smtp-pbrfid">

              <remote-destination host="smtpout.secureserver.net" port="80"/>

              </outbound-socket-binding>

               

               


              public Session getValue() throws IllegalStateException, IllegalArgumentException {

               


              Credentials credentials = config.getSmtpServer().getCredentials();

              Authenticator authenticator = null;

              if(credentials != null) {

              authenticator = new Authenticator(credentials.getUsername(), credentials.getPassword());

              }

               


              final Session session = Session.getInstance(props, authenticator);

              setAuthentication(session);

              return session;

              }

               


              private class Authenticator extends javax.mail.Authenticator {

              private PasswordAuthentication authentication;

               


              public Authenticator(String username, String password) {

              authentication = new PasswordAuthentication(username, password);

              }

               


              protected PasswordAuthentication getPasswordAuthentication() {

              return authentication;

              }

              }
              • 19. Re: JavaMail support on AS7
                alfred.graber

                Hi Walter

                 

                I do not think, Tomaz has put it in the head - so I suppose it is not in the hudson build yet...

                 

                So maybe ask him to do so

                 

                Alfred

                • 20. Re: JavaMail support on AS7
                  ctomc

                  Hi guys,

                   

                  yes it is not in head/upstream yet, as I am working on management aspect of subsystem to make it manageable trough admin console...

                   

                  in the mean time you can use my fixes by putting attached two files in JBOSS_HOME/modules/org/jboss/as/mail/main and delete all files previously there.

                   

                  The code will be in upstream before CR1 is released...

                   

                  cheers,

                  tomaz

                  • 21. Re: JavaMail support on AS7
                    whutchinson

                    The files you provided works perfectly.

                     

                    Thanks,

                    Hutch

                    • 22. Re: JavaMail support on AS7
                      blabno

                      Has this made into 7.1.0.CR1?

                      • 23. Re: JavaMail support on AS7
                        ctomc

                        Unfortunately no, I have missed the deadline for few hours.

                         

                        It is in upstream now, so you can use nightly build or manually apply patch from this thread.

                        • 24. Re: JavaMail support on AS7
                          chufaca

                          I want to ask something related to the topic here:

                          I'm using 7.1.0.CR1b, and the configuration of the JavaMail doesn't work properly, I'm receiving a "09:20:55,156 ERROR [stderr] (MSC service thread 1-4) javax.naming.CommunicationException: Receive timed out [Root exception is java.net.SocketTimeoutException: Receive timed out]".

                           

                          The java code works fine in JBoss 5, but not with this version.

                          Here I give you my config file if needed:

                           

                          <subsystem xmlns="urn:jboss:domain:mail:1.0">

                          <mail-session jndi-name="java:/Mail" debug="true">

                          <smtp-server outbound-socket-binding-ref="mail-smtp"/>

                          </mail-session>

                          </subsystem>

                           

                          And in the socket-binding-group:

                           

                          <outbound-socket-binding name="mail-smtp">

                          <remote-destination host="localhost" port="25"/>

                          </outbound-socket-binding>

                           

                          I appreciate any help. Thanks in advance

                          Facu

                          • 25. Re: JavaMail support on AS7
                            ctomc

                            Hi,

                             

                            this looks like problem with connecting to localhost port 25,

                             

                            can you please try with latest nightly build https://ci.jboss.org/jenkins/job/JBoss-AS-7.x-latest/ (this is really close to 7.1.0.Final)

                            if it still does not work, post while stack trace.

                             

                            otherwise please create new thread as it is different problem that original thread.

                             

                             

                            cheers,

                            tomaz

                            • 26. Re: JavaMail support on AS7
                              user1919

                              Hello Tomaz,

                               

                              I am trying to connect with JBoss 7.1.1 to an own configured server (postfix) that uses TLS. No success, with your patch files or some others. I get some strange authentication error. I believe my server to be properly configured, since I tried it with Thunderbird, and the option starttls and it works fine. Do you have any idea/suggestion on what to do?

                              • 27. Re: JavaMail support on AS7
                                ctomc

                                Hi Ignacio,

                                 

                                I am not sure connecting to TLS servers works as i don't have any way of testing it... The code for doing that is in place and it "should" work...

                                 

                                Can you create a new thread about this as this is issue just with TLS, and plase post you configuration (ofcourse mask un/pw)

                                 

                                --

                                tomaz

                                1 2 Previous Next