Running an application in Payara you can use a Mail Resource to send mails via SMTP.
In your Java EE code you can inject a Mail Resource by its name:
@Resource(lookup = "mail/my.mail.session")
....
Transport trans = mailSession.getTransport("smtp");
trans.connect();
.....
The Mail resource can be declared in the Payra Web Admin Console in the section “Resources ->JavaMail Sessions”.
Or you can define a mail resource directly in the domain.xml file:
....
<resources>
...
<mail-resource auth="false" host="smarthost" from="info@foo.com" user="admin" jndi-name="mail/my.mail.session"></mail-resource>
</resources>
<servers>
<server config-ref="server-config" name="server">
....
<resource-ref ref="mail/my.mail.session"></resource-ref>
</server>
</servers>
....
If you define the mail resource directyl in your domain.xml file take care about the ‘resource-ref’ declaration in the seciton ‘<servers>’. If you miss this, than your application will not find the mail resource to be injected!