diff --git a/appengine/mailgun/src/main/java/com/example/appengine/mailgun/MailgunServlet.java b/appengine/mailgun/src/main/java/com/example/appengine/mailgun/MailgunServlet.java
index 6d03cc29449..899d983a0b0 100644
--- a/appengine/mailgun/src/main/java/com/example/appengine/mailgun/MailgunServlet.java
+++ b/appengine/mailgun/src/main/java/com/example/appengine/mailgun/MailgunServlet.java
@@ -27,7 +27,6 @@
import java.io.File;
import java.io.IOException;
-import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
@@ -35,7 +34,6 @@
// [START example]
@SuppressWarnings("serial")
-@WebServlet(name = "mailgun", value = "/send/email")
public class MailgunServlet extends HttpServlet {
private static final String MAILGUN_DOMAIN_NAME = System.getenv("MAILGUN_DOMAIN_NAME");
diff --git a/appengine/mailjet/README.md b/appengine/mailjet/README.md
new file mode 100644
index 00000000000..0a9bddaaac7
--- /dev/null
+++ b/appengine/mailjet/README.md
@@ -0,0 +1,15 @@
+# Mailjet sample for Google App Engine
+This sample demonstrates how to use [Mailjet](https://www.mailjet.com/) on Google Managed VMs to
+send emails from a verified sender you own.
+
+## Setup
+1. Before using, ensure the address you plan to send from has been verified in Mailjet.
+
+## Running locally
+ $ export MAILJET_API_KEY=[your mailjet api key]
+ $ export MAILJET_SECRET_KEY=[your mailjet secret key]
+ $ mvn clean appengine:devserver
+
+## Deploying
+1. Edit the environment variables in the appengine-web.xml with the appropriate Mailjet values.
+ $ mvn clean appengine:update
diff --git a/appengine/mailjet/pom.xml b/appengine/mailjet/pom.xml
new file mode 100644
index 00000000000..46a3c91d259
--- /dev/null
+++ b/appengine/mailjet/pom.xml
@@ -0,0 +1,72 @@
+
+
+ 4.0.0
+ war
+ 1.0-SNAPSHOT
+ com.example.appengine
+ appengine-mailjet
+
+ com.google.cloud
+ doc-samples
+ 1.0.0
+ ../..
+
+
+
+ com.mailjet
+ mailjet-client
+ 3.1.1
+ system
+ ${project.basedir}/src/main/webapp/WEB-INF/lib/client-3.1.1-jar-with-dependencies.jar
+
+
+ javax.servlet
+ javax.servlet-api
+ 3.1.0
+ jar
+ provided
+
+
+
+ com.sun.jersey
+ jersey-core
+ 1.19.1
+
+
+ com.sun.jersey
+ jersey-client
+ 1.19.1
+
+
+ com.sun.jersey.contribs
+ jersey-multipart
+ 1.19.1
+
+
+
+
+
+ ${project.build.directory}/${project.build.finalName}/WEB-INF/classes
+
+
+ com.google.appengine
+ appengine-maven-plugin
+ ${appengine.sdk.version}
+
+
+
+
diff --git a/appengine/mailjet/src/main/java/com/example/appengine/mailjet/MailjetServlet.java b/appengine/mailjet/src/main/java/com/example/appengine/mailjet/MailjetServlet.java
new file mode 100644
index 00000000000..e5528dd540f
--- /dev/null
+++ b/appengine/mailjet/src/main/java/com/example/appengine/mailjet/MailjetServlet.java
@@ -0,0 +1,67 @@
+/**
+ * Copyright 2016 Google Inc. All Rights Reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.example.appengine.mailjet;
+
+import com.mailjet.client.MailjetClient;
+import com.mailjet.client.MailjetRequest;
+import com.mailjet.client.MailjetResponse;
+import com.mailjet.client.errors.MailjetException;
+import com.mailjet.client.resource.Email;
+
+import org.json.JSONArray;
+import org.json.JSONObject;
+
+import java.io.IOException;
+
+import javax.servlet.ServletException;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+@SuppressWarnings("serial")
+public class MailjetServlet extends HttpServlet {
+ private static final String MAILJET_API_KEY = System.getenv("MAILJET_API_KEY");
+ private static final String MAILJET_SECRET_KEY = System.getenv("MAILJET_SECRET_KEY");
+ private MailjetClient client = new MailjetClient(MAILJET_API_KEY, MAILJET_SECRET_KEY);
+
+ @Override
+ public void doPost(HttpServletRequest req, HttpServletResponse resp) throws IOException,
+ ServletException {
+ String recipient = req.getParameter("to");
+ String sender = req.getParameter("from");
+
+ MailjetRequest email = new MailjetRequest(Email.resource)
+ .property(Email.FROMEMAIL, sender)
+ .property(Email.FROMNAME, "pandora")
+ .property(Email.SUBJECT, "Your email flight plan!")
+ .property(Email.TEXTPART,
+ "Dear passenger, welcome to Mailjet! May the delivery force be with you!")
+ .property(Email.HTMLPART,
+ "
Dear passenger, welcome to Mailjet!
May the delivery force be with you!")
+ .property(Email.RECIPIENTS, new JSONArray().put(new JSONObject().put("Email", recipient)));
+
+ try {
+ // trigger the API call
+ MailjetResponse response = client.post(email);
+ // Read the response data and status
+ resp.getWriter().print(response.getStatus());
+ resp.getWriter().print(response.getData());
+ } catch (MailjetException e) {
+ throw new ServletException("Mailjet Exception", e);
+ }
+ }
+}
diff --git a/appengine/mailjet/src/main/webapp/WEB-INF/appengine-web.xml b/appengine/mailjet/src/main/webapp/WEB-INF/appengine-web.xml
new file mode 100644
index 00000000000..5e127cc369f
--- /dev/null
+++ b/appengine/mailjet/src/main/webapp/WEB-INF/appengine-web.xml
@@ -0,0 +1,24 @@
+
+
+
+
+
+ YOUR-PROJECT-ID
+ YOUR-VERSION-ID
+ true
+
+
+
+
+
diff --git a/appengine/mailjet/src/main/webapp/WEB-INF/lib/client-3.1.1-jar-with-dependencies.jar b/appengine/mailjet/src/main/webapp/WEB-INF/lib/client-3.1.1-jar-with-dependencies.jar
new file mode 100644
index 00000000000..e3b58094cf6
Binary files /dev/null and b/appengine/mailjet/src/main/webapp/WEB-INF/lib/client-3.1.1-jar-with-dependencies.jar differ
diff --git a/appengine/mailjet/src/main/webapp/WEB-INF/web.xml b/appengine/mailjet/src/main/webapp/WEB-INF/web.xml
new file mode 100644
index 00000000000..e0d543ad029
--- /dev/null
+++ b/appengine/mailjet/src/main/webapp/WEB-INF/web.xml
@@ -0,0 +1,28 @@
+
+
+
+
+
+
+ mailjet
+ com.example.appengine.mailjet.MailjetServlet
+
+
+ mailjet
+ /send/email
+
+
diff --git a/appengine/mailjet/src/main/webapp/index.html b/appengine/mailjet/src/main/webapp/index.html
new file mode 100644
index 00000000000..037fddcea91
--- /dev/null
+++ b/appengine/mailjet/src/main/webapp/index.html
@@ -0,0 +1,27 @@
+
+
+
+
+ Mailgun on Google App Engine Managed VMs
+
+
+
+
+
+
+
diff --git a/managed_vms/datastore/src/main/appengine/app.yaml b/managed_vms/datastore/src/main/appengine/app.yaml
index 2a659160df5..b45dd027208 100644
--- a/managed_vms/datastore/src/main/appengine/app.yaml
+++ b/managed_vms/datastore/src/main/appengine/app.yaml
@@ -1,3 +1,18 @@
+# Copyright 2016 Google Inc. All Rights Reserved.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
runtime: java
vm: true
diff --git a/managed_vms/mailjet/README.md b/managed_vms/mailjet/README.md
new file mode 100644
index 00000000000..37289ddc7fb
--- /dev/null
+++ b/managed_vms/mailjet/README.md
@@ -0,0 +1,15 @@
+# Mailjet sample for Google Managed VMs
+This sample demonstrates how to use [Mailjet](https://www.mailjet.com/) on Google Managed VMs to
+send emails from a verified sender you own.
+
+## Setup
+1. Before using, ensure the address you plan to send from has been verified in Mailjet.
+
+## Running locally
+ $ export MAILJET_API_KEY=[your mailjet api key]
+ $ export MAILJET_SECRET_KEY=[your mailjet secret key]
+ $ mvn clean jetty:run
+
+## Deploying
+1. Edit the environment variables in the app.yaml with the appropriate Mailjet values.
+ $ mvn clean gcloud:deploy
diff --git a/managed_vms/mailjet/pom.xml b/managed_vms/mailjet/pom.xml
new file mode 100644
index 00000000000..6fb3a3bf061
--- /dev/null
+++ b/managed_vms/mailjet/pom.xml
@@ -0,0 +1,96 @@
+
+
+ 4.0.0
+ war
+ 1.0-SNAPSHOT
+ com.example.managedvms
+ managed-vms-mailjet
+
+ com.google.cloud
+ doc-samples
+ 1.0.0
+ ../..
+
+
+
+
+ com.mailjet
+ mailjet-client
+ 3.1.1
+ system
+ ${project.basedir}/src/main/webapp/WEB-INF/lib/client-3.1.1-jar-with-dependencies.jar
+
+
+
+ javax.servlet
+ javax.servlet-api
+ 3.1.0
+ jar
+ provided
+
+
+
+ com.sun.jersey
+ jersey-core
+ 1.19.1
+
+
+ com.sun.jersey
+ jersey-client
+ 1.19.1
+
+
+ com.sun.jersey.contribs
+ jersey-multipart
+ 1.19.1
+
+
+
+
+
+ ${project.build.directory}/${project.build.finalName}/WEB-INF/classes
+
+
+ com.google.appengine
+ gcloud-maven-plugin
+ 2.0.9.101.v20160316
+
+
+ org.apache.maven.plugins
+ maven-war-plugin
+ 2.6
+
+ false
+
+
+
+ org.apache.maven.plugins
+ 3.3
+ maven-compiler-plugin
+
+
+ 1.8
+
+
+
+ org.eclipse.jetty
+ jetty-maven-plugin
+ 9.3.7.v20160115
+
+
+
+
diff --git a/managed_vms/mailjet/src/main/appengine/app.yaml b/managed_vms/mailjet/src/main/appengine/app.yaml
new file mode 100644
index 00000000000..3b3ed8ecd1d
--- /dev/null
+++ b/managed_vms/mailjet/src/main/appengine/app.yaml
@@ -0,0 +1,13 @@
+runtime: java
+vm: true
+
+handlers:
+- url: /.*
+ script: this field is required, but ignored
+ secure: always
+
+# [START env_variables]
+env_variables:
+ MAILJET_API_KEY: YOUR-MAILJET-API-KEY
+ MAILJET_SECRET_KEY: YOUR-MAILJET-SECRET-KEY
+# [END env_variables]
\ No newline at end of file
diff --git a/managed_vms/mailjet/src/main/java/com/example/managedvms/mailjet/MailjetServlet.java b/managed_vms/mailjet/src/main/java/com/example/managedvms/mailjet/MailjetServlet.java
new file mode 100644
index 00000000000..8fedc3cf636
--- /dev/null
+++ b/managed_vms/mailjet/src/main/java/com/example/managedvms/mailjet/MailjetServlet.java
@@ -0,0 +1,69 @@
+/**
+ * Copyright 2016 Google Inc. All Rights Reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.example.managedvms.mailjet;
+
+import com.mailjet.client.MailjetClient;
+import com.mailjet.client.MailjetRequest;
+import com.mailjet.client.MailjetResponse;
+import com.mailjet.client.errors.MailjetException;
+import com.mailjet.client.resource.Email;
+
+import org.json.JSONArray;
+import org.json.JSONObject;
+
+import java.io.IOException;
+
+import javax.servlet.ServletException;
+import javax.servlet.annotation.WebServlet;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+@SuppressWarnings("serial")
+@WebServlet(name = "mailjet", value = "/send/email")
+public class MailjetServlet extends HttpServlet {
+ private static final String MAILJET_API_KEY = System.getenv("MAILJET_API_KEY");
+ private static final String MAILJET_SECRET_KEY = System.getenv("MAILJET_SECRET_KEY");
+ private MailjetClient client = new MailjetClient(MAILJET_API_KEY, MAILJET_SECRET_KEY);
+
+ @Override
+ public void doPost(HttpServletRequest req, HttpServletResponse resp) throws IOException,
+ ServletException {
+ String recipient = req.getParameter("to");
+ String sender = req.getParameter("from");
+
+ MailjetRequest email = new MailjetRequest(Email.resource)
+ .property(Email.FROMEMAIL, sender)
+ .property(Email.FROMNAME, "pandora")
+ .property(Email.SUBJECT, "Your email flight plan!")
+ .property(Email.TEXTPART,
+ "Dear passenger, welcome to Mailjet! May the delivery force be with you!")
+ .property(Email.HTMLPART,
+ "
Dear passenger, welcome to Mailjet!
May the delivery force be with you!")
+ .property(Email.RECIPIENTS, new JSONArray().put(new JSONObject().put("Email", recipient)));
+
+ try {
+ // trigger the API call
+ MailjetResponse response = client.post(email);
+ // Read the response data and status
+ resp.getWriter().print(response.getStatus());
+ resp.getWriter().print(response.getData());
+ } catch (MailjetException e) {
+ throw new ServletException("Mailjet Exception", e);
+ }
+ }
+}
diff --git a/managed_vms/mailjet/src/main/webapp/WEB-INF/lib/client-3.1.1-jar-with-dependencies.jar b/managed_vms/mailjet/src/main/webapp/WEB-INF/lib/client-3.1.1-jar-with-dependencies.jar
new file mode 100644
index 00000000000..e3b58094cf6
Binary files /dev/null and b/managed_vms/mailjet/src/main/webapp/WEB-INF/lib/client-3.1.1-jar-with-dependencies.jar differ
diff --git a/managed_vms/mailjet/src/main/webapp/index.html b/managed_vms/mailjet/src/main/webapp/index.html
new file mode 100644
index 00000000000..037fddcea91
--- /dev/null
+++ b/managed_vms/mailjet/src/main/webapp/index.html
@@ -0,0 +1,27 @@
+
+
+
+
+ Mailgun on Google App Engine Managed VMs
+
+
+
+
+
+
+
diff --git a/pom.xml b/pom.xml
index f8c1c03c096..acbdd279cc5 100644
--- a/pom.xml
+++ b/pom.xml
@@ -47,6 +47,7 @@
appengine/appidentityappengine/helloworldappengine/mailgun
+ appengine/mailjetappengine/memcacheappengine/sendgridappengine/static-files
@@ -62,6 +63,7 @@
managed_vms/extending-runtimemanaged_vms/helloworldmanaged_vms/mailgun
+ managed_vms/mailjetmanaged_vms/memcachemanaged_vms/sendgridmanaged_vms/sparkjava