Java SendGrid Email Sample for Google Compute Engine
See the sample application documentaion for more detailed instructions.
For more information about SendGrid, see their documentation.
Running on Compute Engine
To run the sample, you will need to do the following:
Create a SendGrid Account. As of September 2015, Google users start with 25,000 free emails per month.
Create a compute instance on the Google Cloud Platform Developer's Console
SSH into the instance you created
Update packages and install required packages
sudo apt-get update && sudo apt-get install git-core openjdk-8-jdk maven
Clone the repo
git clone https://github.com/GoogleCloudPlatform/java-docs-samples.git
Configure your SendGrid settings in the java class (
Navigate back to
./sendgridand use maven to package the class as a jar
mvn clean package
Switch to the target directory with the jar file and enable execution on that file
chmod +x compute-sendgrid-1.0-SNAPSHOT-jar-with-dependencies.jar
Make sure that openjdk 8 is the selected java version
sudo update-alternatives --config java
Execute the jar file and send an email (make sure you are in the target folder)
java -jar compute-sendgrid-1.0-SNAPSHOT-jar-with-dependencies.jar