If you find your application has the need to exchange mail with Google’s mail servers you’ll need to tweek your WildFly configuration file a bit in order to expose Gmail via JNDI to your application.
Find <subsystem xmlns=”urn:jboss:domain:mail:2.0″> and add the snippet:
<mail-session name=”java:jboss/mail/Gmail” from=”username@gmail.com” jndi-name=”java:jboss/mail/Gmail”>
<smtp-server password=”YourSecretPassword” username=”username@gmail.com” ssl=”true” outbound-socket-binding-ref=”mail-smtp-gmail”/>
</mail-session>
Find <socket-binding-group name=”standard-sockets” default-interface=”public” port-offset=”${jboss.socket.binding.port-offset:0}”> and add the snippet:
<outbound-socket-binding name=”mail-smtp-gmail” source-port=”0″ fixed-source-port=”false”>
<remote-destination host=”smtp.gmail.com” port=”465″/>
</outbound-socket-binding>
Restart WildFly and you should now be able to use GMail via a JNDI/Resource lookup java:jboss/mail/Gmail
[…] WildFly but should still be useful: https://dennis.gesker.com/2016/02/16/wildfly-10-and-wflytx0013/ https://dennis.gesker.com/2016/02/16/add-gmail-mail-session-to-wildfly-10/ https://dennis.gesker.com/2017/08/02/wildfly-10-1-warnings-tweaking-ubuntu-17-04/ […]
LikeLike