This "How To Guide" provides a the boilerplate needed to send e-mail via gmail in Java. This uses Java Mail, a feature of Java EE. The logic to send the mail is wrapped in a servlet for simple testing.
This guide presumes knowledge on install and use of the following:
- Gradle
- Liberty
- WebSphere Developer Tools (WDT)
- Step 1 - Build the WAR
- Run
gradle
to build the WAR inbuild/libs/howto-java-gmail.war
- Run
- Step 2 - Create the server
- Copy
howto-java-gmail
to your Liberty servers directory cp -r howto-java-gmail/ wlp_user_dir/servers/howto-java-gmail/
- Copy
- Step 3 - Start the server
bin/server run howto-java-gmail
- Step 4 - Deploy the WAR
- Move the built WAR into
dropins
mv build/libs/howto-java-gmail.war wlp_user_dir/servers/howto-java-gmail/dropins
- Move the built WAR into
The following are high-level instructions for importing this project into Eclipse
- Run
gradle eclipse
to generate the .project and other files needed by Eclipse - Import -> Projects from Git
This boilerplate was lifted / inspiried by two very useful resources: mkyong.com's guide JavaMail API – Sending email via Gmail SMTP example and wasdev's guide How to write an application using JavaMail