Sending Email with Mailgun
Note: Mailgun is a third-party company whose services are not covered by the Google App Engine Service Level Agreement.
The Mailgun API is built on HTTP and is RESTful. It uses predictable, resource- oriented URLs and built-in HTTP capabilities for passing parameters and authentication. The Mailgun API responds with standard HTTP response codes to indicate errors, and returns JSON.
Mailgun has published libraries for various languages. You can use these libraries or your favorite HTTP/REST library to make HTTP calls to Mailgun.
For more code samples in other programming languages, see Mailgun's documentation.
Contents
Pricing
As a Google Cloud Platform user, your first 30,000 messages are free every month. See the monthly pricing calculator on the sign up page for pricing on additional messages and volume discounts.
Setup
To ensure you get special pricing as a Google Cloud Platform customer, use the sign-up portal to create a new Mailgun account.
Add the required jersey REST client modules to your application. For example, if you use Maven, add to the project's pom.xml:
\[This section requires a browser that supports JavaScript and iframes.\]
Sending a plain text email
appengine/mailgun/src/main/java/com/example/appengine/mailgun/MailgunServlet.java
\[This section requires a browser that supports JavaScript and iframes.\]
Sending an HTML and text email
Sending a message with HTML and text parts. This example also attaches files to the message:
appengine/mailgun/src/main/java/com/example/appengine/mailgun/MailgunServlet.java
\[This section requires a browser that supports JavaScript and iframes.\]
Sample response:
Learning more
For more detailed examples and information, including how to track and route messages, see Mailgun's documentation.