# Mailgun (/integrations/mailgun)

Use cases and templates: [Mailgun integration for AI agents](https://www.sim.ai/integrations/mailgun)





<BlockInfoCard type="mailgun" color="#C12126" />

{/* MANUAL-CONTENT-START:intro */}

Use [Mailgun](https://www.mailgun.com) to send text or HTML emails, retrieve messages and delivery events, manage mailing lists, and inspect sending domains. Tags help associate sent messages with a workflow or campaign.

{/* MANUAL-CONTENT-END */}

## Use the block [#usage-instructions]

Send transactional emails, manage mailing lists and members, view domain information, and track email events. Supports text and HTML emails, tags for tracking, and comprehensive list management.

## Actions [#actions]

### Mailgun Send Message [#mailgun-send-message]

Send an email using Mailgun API

#### Input [#input]

| Parameter | Type | Required | Description |
| - | - | - | - |
| `apiKey` | string | Yes | Mailgun API key |
| `region` | string | No | Mailgun account region: "us" (default) or "eu" |
| `domain` | string | Yes | Mailgun sending domain (e.g., mg.example.com) |
| `from` | string | Yes | Sender email address (e.g., [sender@example.com](mailto:sender@example.com) or "Name \<[sender@example.com](mailto:sender@example.com)>") |
| `to` | string | Yes | Recipient email address (e.g., [user@example.com](mailto:user@example.com)). Use comma-separated values for multiple recipients |
| `subject` | string | Yes | Email subject line |
| `text` | string | No | Plain text body of the email |
| `html` | string | No | HTML body of the email (e.g., "\<h1>Hello\</h1>\<p>Message content\</p>") |
| `cc` | string | No | CC recipient email address (e.g., [cc@example.com](mailto:cc@example.com)). Use comma-separated values for multiple recipients |
| `bcc` | string | No | BCC recipient email address (e.g., [bcc@example.com](mailto:bcc@example.com)). Use comma-separated values for multiple recipients |
| `tags` | string | No | Tags for the email (comma-separated) |

#### Output [#output]

| Parameter | Type | Description |
| - | - | - |
| `success` | boolean | Whether the message was sent successfully |
| `id` | string | Message ID |
| `message` | string | Response message from Mailgun |

### Mailgun Get Message [#mailgun-get-message]

Retrieve a stored message by its key

#### Input [#input-1]

| Parameter | Type | Required | Description |
| - | - | - | - |
| `apiKey` | string | Yes | Mailgun API key |
| `region` | string | No | Mailgun account region: "us" (default) or "eu" |
| `domain` | string | Yes | Mailgun domain for retrieving messages (e.g., mg.example.com) |
| `messageKey` | string | Yes | Message storage key |

#### Output [#output-1]

| Parameter | Type | Description |
| - | - | - |
| `success` | boolean | Whether the request was successful |
| `recipients` | string | Message recipients |
| `from` | string | Sender email |
| `subject` | string | Message subject |
| `bodyPlain` | string | Plain text body |
| `strippedText` | string | Stripped text |
| `strippedSignature` | string | Stripped signature |
| `bodyHtml` | string | HTML body |
| `strippedHtml` | string | Stripped HTML |
| `attachmentCount` | number | Number of attachments |
| `timestamp` | number | Message timestamp |
| `messageHeaders` | json | Message headers |
| `contentIdMap` | json | Content ID map |

### Mailgun List Messages [#mailgun-list-messages]

List events (logs) for messages sent through Mailgun

#### Input [#input-2]

| Parameter | Type | Required | Description |
| - | - | - | - |
| `apiKey` | string | Yes | Mailgun API key |
| `region` | string | No | Mailgun account region: "us" (default) or "eu" |
| `domain` | string | Yes | Mailgun domain for listing events (e.g., mg.example.com) |
| `event` | string | No | Filter by event type (accepted, delivered, failed, opened, clicked, etc.) |
| `limit` | number | No | Maximum number of events to return (default: 100) |

#### Output [#output-2]

| Parameter | Type | Description |
| - | - | - |
| `success` | boolean | Whether the request was successful |
| `items` | json | Array of event items |
| `paging` | json | Paging information |

### Mailgun Create Mailing List [#mailgun-create-mailing-list]

Create a new mailing list

#### Input [#input-3]

| Parameter | Type | Required | Description |
| - | - | - | - |
| `apiKey` | string | Yes | Mailgun API key |
| `region` | string | No | Mailgun account region: "us" (default) or "eu" |
| `address` | string | Yes | Mailing list address (e.g., [newsletter@mg.example.com](mailto:newsletter@mg.example.com)) |
| `name` | string | No | Mailing list name |
| `description` | string | No | Mailing list description |
| `accessLevel` | string | No | Access level: readonly, members, or everyone |

#### Output [#output-3]

| Parameter | Type | Description |
| - | - | - |
| `success` | boolean | Whether the list was created successfully |
| `message` | string | Response message |
| `list` | json | Created mailing list details |

### Mailgun Get Mailing List [#mailgun-get-mailing-list]

Get details of a mailing list

#### Input [#input-4]

| Parameter | Type | Required | Description |
| - | - | - | - |
| `apiKey` | string | Yes | Mailgun API key |
| `region` | string | No | Mailgun account region: "us" (default) or "eu" |
| `address` | string | Yes | Mailing list address to retrieve (e.g., [newsletter@mg.example.com](mailto:newsletter@mg.example.com)) |

#### Output [#output-4]

| Parameter | Type | Description |
| - | - | - |
| `success` | boolean | Whether the request was successful |
| `list` | json | Mailing list details |

### Mailgun Add List Member [#mailgun-add-list-member]

Add a member to a mailing list

#### Input [#input-5]

| Parameter | Type | Required | Description |
| - | - | - | - |
| `apiKey` | string | Yes | Mailgun API key |
| `region` | string | No | Mailgun account region: "us" (default) or "eu" |
| `listAddress` | string | Yes | Mailing list address (e.g., [list@mg.example.com](mailto:list@mg.example.com)) |
| `address` | string | Yes | Member email address to add (e.g., [user@example.com](mailto:user@example.com)) |
| `name` | string | No | Member name |
| `vars` | string | No | JSON string of custom variables |
| `subscribed` | boolean | No | Whether the member is subscribed |

#### Output [#output-5]

| Parameter | Type | Description |
| - | - | - |
| `success` | boolean | Whether the member was added successfully |
| `message` | string | Response message |
| `member` | json | Added member details |

### Mailgun List Domains [#mailgun-list-domains]

List all domains for your Mailgun account

#### Input [#input-6]

| Parameter | Type | Required | Description |
| - | - | - | - |
| `apiKey` | string | Yes | Mailgun API key |
| `region` | string | No | Mailgun account region: "us" (default) or "eu" |

#### Output [#output-6]

| Parameter | Type | Description |
| - | - | - |
| `success` | boolean | Whether the request was successful |
| `totalCount` | number | Total number of domains |
| `items` | json | Array of domain objects |

### Mailgun Get Domain [#mailgun-get-domain]

Get details of a specific domain

#### Input [#input-7]

| Parameter | Type | Required | Description |
| - | - | - | - |
| `apiKey` | string | Yes | Mailgun API key |
| `region` | string | No | Mailgun account region: "us" (default) or "eu" |
| `domain` | string | Yes | Domain name to retrieve details for (e.g., mg.example.com) |

#### Output [#output-7]

| Parameter | Type | Description |
| - | - | - |
| `success` | boolean | Whether the request was successful |
| `domain` | json | Domain details |
