The latest version of Payara Server extends the Notification Service with many ways how to process notifications and send them to external services. Sending notifications as email messages to an SMTP server is now provided out of the box. It is even possible to use an account on a public email server, such as Gmail. In this guest blog, Alessio Gennari - a member of the Payara open source community - explains to you exactly how it can be done.
To successfully configure a JavaMail Session in Payara Server 171 with your Gmail account, first you need to modify the following settings for a JavaMail session in Payara Server:
- set JNDI Name with a name that will be used to refer to it from the Notification Service
- set Mail Host to smtp.gmail.com
- set Default User with your gmail address
- set Default Sender Address with any email address you prefer
Now you need to set some additional properties of the JavaMail Session to enable Payara Server to send emails through your Gmail account. Here are the properties you have to set:
- mail.smtp.password=<gmail account password>
- mail.smtp.user=<gmail account email address>
You can find the correct settings in the following figure:
All other settings can be left at default values.
Now you can enable email notifications using the JNDI name of the JavaMail session, and Payara Server can send notifications via your Gmail account.