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.
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.
- You may need a MultiDict class to represent HTTP requests with multiple values per key, such as WebOb’s MultiDict or Werkzeug/Flask's MultiDict.
Sending a plain text email
Sending an HTML and text email
Sending a message with HTML and text parts:
Sample response:
{
"message": "Queued. Thank you.",
"id": "<[email protected]>"
}
Learning more
For more detailed examples and information, including how to track and route messages, see Mailgun's documentation.