Welcome to the Mailgun API Documentation
Here you can find comprehensive information about the Mailgun API, a powerful email delivery service. Whether you’re a developer or a business looking to integrate Mailgun into your application or website, this documentation will help you get started.
Getting Started
1. Sign-up for Mailgun
If you haven’t already, you should sign up for a Mailgun account to access the API. Visit the Mailgun website and follow the registration process.
2. Obtain API Key
After signing up, you’ll need to obtain your API key. This key is crucial for authenticating your API calls. Go to your Mailgun account settings and locate the API Keys section to generate your unique API key.
3. API Documentation
Below, you will find detailed information on each endpoint and available parameters. Familiarize yourself with the API endpoints and request/response structures.
To make it easier for you, the documentation is organized into relevant categories for quick reference. Please refer to the corresponding sections below.
API Usage
Sending Emails
The Mailgun API allows you to send emails programmatically. Here’s an overview of the steps involved:
- Make a POST request to the /messages endpoint.
- Include the required parameters such as
from
,to
, andsubject
. - Optionally, add additional parameters like
cc
,bcc
,attachments
, etc. - Send the request and handle the response accordingly.
Tracking and Analytics
Mailgun API provides powerful tracking and analytics features. You can:
- Retrieve information about sent messages, including their status and delivery status.
- Handle events such as opens, clicks, and unsubscribes.
- Generate statistics about your email campaigns.
API Documentation Directory
1. Sending Messages
Endpoint: /messages
This endpoint enables you to send email messages to one or multiple recipients.
Click to expand
Parameters:
from
– Sender’s email address.to
– Recipient’s email address(es).subject
– Email subject.text
– Plain text email content.html
– HTML email content (optional).cc
– Carbon copy email addresses (optional).bcc
– Blind carbon copy email addresses (optional).attachments
– Attachments (optional).
Example:
// Sample POST request to send an email
POST /messages
{
"from": "sender@example.com",
"to": "recipient@example.com",
"subject": "Hello",
"text": "This is the message content."
}
2. Event Webhook
Endpoint: /webhooks/events
This endpoint allows you to configure a webhook URL where Mailgun can send events related to your email messages.
Click to expand
Parameters:
url
– The URL where Mailgun should send the event data.
Additional Resources
For further information and advanced usage, check out these resources:
- Official Mailgun Documentation
- Mailgun PHP SDK on GitHub
- Mailgun-related questions on Stack Overflow
Conclusion
With the Mailgun API, you have the ability to send emails, track events, and gather valuable analytics. Explore further to leverage the full potential of Mailgun for your application or business.