2 Replies Latest reply on Oct 31, 2016 6:42 PM by Bill Shannon

    Using oauth2 for smtp mail in Wildfly 10

    Craig Bensemann Novice

      Hi

       

      I'm wanting to configure an smtp server in wildfly for use in sending emails from a webapp. The smtp server uses oauth authentication (gmail). Is this possible?

       

      I know you can make your gmail account "less secure" and disable the need for oauth but I don't want to do that.

       

      I've managed to get it to work by configuring a custom-server similar to the example below (sorry not on the right computer to check the actual code just now)

       

                  <custom-server name="smtp" password="access_token" username="myemail@gmail.com" ssl="false" tls="true" outbound-socket-binding-ref="gmail-smtp">
                      <property name="mail.imap.auth.mechanisms" value="XOAUTH2" />
                  </custom-server>
              </mail-session>

       

      My problem is that after the access_token expires this solution will stop working. Is there a correct way of configuring mail with oauth and providing a refresh_token so that it always has valid credentials to the server?

       

       

      thanks

      Craig