This sample demonstrates how to use Mailjet on Google Compute Engine
See the sample application documentaion for more detailed instructions.
For more information about Mailjet, see their documentation.
To run the sample, you will need to do the following:
-
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 Mailjet settings in the java class (MAILJET_API_KEY, SENDGRID_SENDER)
java-docs-samples/compute/mailjet/src/main/java/com/example/compute/mailjet/MailjetSender.java
-
Navigate back to ./Mailjet and use maven to package the class as a jar
mvn clean package
-
Make sure that openjdk 8 is the selected java version
sudo update-alternatives --config java
-
Execute the jar file with your intended recipient and sender emails as arguments and send an email (make sure you are in the target folder)
java -jar compute-mailjet-1.0-SNAPSHOT-jar-with-dependencies.jar [RECIPIENT EMAIL] [SENDER EMAIL]