9 Replies Latest reply on Nov 7, 2016 8:41 PM by Rudi Adianto

    JBoss 7 JavaMail

    Zdeněk Obst Newbie

      Hello there,

       

      I found out that JBoss AS 7 changed the way of looking at configuration files. I also found out that JavaMail should be supported from version 7.1.x and full (not certified) distribution. Could you please provide some tutorial where to put all the configuration (or show some fragment of standalone.xml) JavaMail session to be accessible via JNDI and @Resource annotation from EJB?

       

      Thanks a lot for all answers

        • 1. Re: JBoss 7 JavaMail
          Tomaz Cerar Master

          Hi,

           

          look into provided standalone.xml where you can find simple example how to configure javamail. just look for mail subsystem.

           

          here are some other options you can use (some of them where added in latest 7.1.0.Final-SNAPSHOT nightly builds)

           

           

          <subsystem xmlns="urn:jboss:domain:mail:1.0">
              <mail-session jndi-name="java:/Mail" from="name dot surname at domain dot tld" >
                  <smtp-server outbound-socket-binding-ref="mail-smtp" ssl="true">
                         <login name="nobody" password="pass"/>
                  </smtp-server>
                  <pop3-server outbound-socket-binding-ref="mail-pop3"/>
                  <imap-server outbound-socket-binding-ref="mail-imap">
                      <login name="nobody" password="pass"/>
                  </imap-server>
             </mail-session>
              <mail-session debug="true" jndi-name="java:jboss/mail/Default" >
                  <smtp-server outbound-socket-binding-ref="mail-smtp"/>
              </mail-session>
          </subsystem>
          

           

          hope it helps,

          tomaz

          • 2. Re: JBoss 7 JavaMail
            Zdeněk Obst Newbie

            Thanks a lot for example. Btw is there any example how to configure correctly SMTPS?:-)

            • 3. Re: JBoss 7 JavaMail
              Tomaz Cerar Master

              Hi,

               

              flag ssl=true controls that. there was also discusion on this matter here:

              http://community.jboss.org/message/639131 there is also a sample config for using gmail's smtp

               

              But please for using ssl + authenfication to smtp(s), use latest nightly build. (any build from this year will be fine)

               

               

              cheers,

              tomaz

              1 of 1 people found this helpful
              • 4. Re: JBoss 7 JavaMail
                Zdeněk Obst Newbie

                Thanks Tomaz again,

                 

                one more thing which is also mentioned in the thread u sent. I'm trying to set-up an gmail imap and Im getting

                530 5.7.0 Must issue a STARTTLS command first.

                 

                I'm using 7.1. CR1 from downloads page. Should I try later nighly build or the problem is elsewhere?

                • 5. Re: JBoss 7 JavaMail
                  Tomaz Cerar Master

                  Hi,

                   

                  you can connect to google via SSL not TLS, I have not managed to make TLS work, Google has also SSL port for all services but it does not adviertize it as much.

                  Can you please try with that. And yes CR1 does not have support for that. I missed deadline for few hours, It is in all nightly builds after new year. Can you try with them first.

                   

                  As for TLS goes, I would like to see what kind of properties did you use in manual config (or before AS7) that made it work? Can you create an jira issue for that and describe it.

                  As just adding "mail.smtp.starttls.enable" did not work for me.

                  But then again, this property is in current implementation of AS7 only set for smtp protocol and I was only trying to make it work with SMTP

                   

                  lp

                  tomaž

                  1 of 1 people found this helpful
                  • 6. Re: JBoss 7 JavaMail
                    Zdeněk Obst Newbie

                    Well .. thanks again:-)

                     

                    Actually I don't need TLS, I was searching for correct SSL port of GMAIL. I maybe mislooked, tried both 465 and 587 but again the server is requesting starttls command. Can you please tell me what SSL port did you tried for gmail?

                     

                    Btw my configuration (maybe i mislooked something):

                     

                    {code.xml}

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

                                <remote-destination host="smtp.gmail.com" port="465"/>

                    </outbound-socket-binding>

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

                               <login username="xyz" password=xyz" ssl="true"/>

                    </smtp-server>

                    {code}

                     

                    Im sorry, am I missing something?

                    • 7. Re: JBoss 7 JavaMail
                      Tomaz Cerar Master

                      Make sure you are using nightly build after 2. of january this year.

                       

                      and sample config is this:

                       

                      <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>
                      

                       

                      Just use this config and replace username and password and it should work.

                       

                      cheers,

                      tomaz

                      • 8. Re: JBoss 7 JavaMail
                        Zdeněk Obst Newbie

                        Sorry for a little late answer but with lastest build I made it finally working. Once again, thanks Tomaz for your time and helpful anwers. Cheers

                        • 9. Re: JBoss 7 JavaMail
                          Rudi Adianto Newbie

                          Sorry for wakening long sleeping thread.

                           

                          How to make mail session login delegated to JAAS, just like datasource connection. Im using jboss 7.2.

                          I took a peek at the source of mail subsystem and I know it is not supported out of the box.

                           

                          Can you point me to the right direction whether to,

                          1. enhance mail subsystem to support jaas login. im ready to get my hand dirty. i know a bit about jboss 7 architecture, however some hint and directions wouldnt hurt. or..

                          2. implement mail as jca resource. if i assume correctly jca subsystem does support security-domain.

                           

                          Thanks!