# Mailgun — Pipedream Connect

> Mailgun is an email automation service built for developers. Powerful transactional email APIs enable you to send, receive, and track emails.

- API slug: `mailgun` (use in MCP headers and tool keys)
- Auth: API key (Pipedream-managed)
- Categories: Marketing
- Website: https://www.mailgun.com/
- This page (HTML): https://pipedream.com/apps/mailgun
- Tools: 11 actions · 11 triggers

## Connect via MCP (recommended)

- Endpoint: `https://remote.mcp.pipedream.net/v3`
- Headers: `Authorization: Bearer <token>` · `x-pd-project-id` · `x-pd-environment` · `x-pd-external-user-id` · `x-pd-app-slug: mailgun`

```ts
import { Client } from "@modelcontextprotocol/sdk/client/index.js"
import { StreamableHTTPClientTransport } from "@modelcontextprotocol/sdk/client/streamableHttp.js"
import { PipedreamClient } from "@pipedream/sdk"

const pd = new PipedreamClient({
  projectId: process.env.PIPEDREAM_PROJECT_ID!,
  clientId: process.env.PIPEDREAM_CLIENT_ID!,
  clientSecret: process.env.PIPEDREAM_CLIENT_SECRET!,
  projectEnvironment: "production",
})

const accessToken = await pd.rawAccessToken

const transport = new StreamableHTTPClientTransport(
  new URL("https://remote.mcp.pipedream.net/v3"),
  {
    requestInit: {
      headers: {
        Authorization: `Bearer ${accessToken}`,
        "x-pd-project-id": process.env.PIPEDREAM_PROJECT_ID!,
        "x-pd-environment": "production",
        "x-pd-external-user-id": "{external_user_id}", // any stable ID for this user in your system
        "x-pd-app-slug": "mailgun",
      },
    },
  },
)

const mcp = new Client({ name: "my-agent", version: "1.0.0" })
await mcp.connect(transport)

const { tools } = await mcp.listTools()

// e.g. run Create Mailing List Member:
const result = await mcp.callTool({
  name: "mailgun-create-mailinglist-member",
  arguments: {
    list: "Mailing List",
    address: "Email Address",
  },
})
```

Docs: [MCP guide](https://pipedream.com/docs/connect/mcp/developers.md)

## API proxy

For a Mailgun endpoint with no pre-built tool, the proxy forwards your request with the connected user's credentials attached.

```bash
# The path segment is the target URL, URL-safe base64 encoded:
# https://api.mailgun.net/v3/domains

curl "https://api.pipedream.com/v1/connect/{project_id}/proxy/aHR0cHM6Ly9hcGkubWFpbGd1bi5uZXQvdjMvZG9tYWlucw?external_user_id={external_user_id}&account_id=apn_xxxxxxx" \
  -H "Authorization: Bearer {access_token}" \
  -H "x-pd-environment: production"
```

Docs: [API proxy guide](https://pipedream.com/docs/connect/api-proxy.md)

## SDK

```ts
import { PipedreamClient } from "@pipedream/sdk"

const pd = new PipedreamClient({
  projectId: process.env.PIPEDREAM_PROJECT_ID!,
  clientId: process.env.PIPEDREAM_CLIENT_ID!,
  clientSecret: process.env.PIPEDREAM_CLIENT_SECRET!,
  projectEnvironment: "production",
})

const result = await pd.actions.run({
  id: "mailgun-create-mailinglist-member",
  externalUserId: "{external_user_id}", // any stable ID for this user in your system
  configuredProps: {
    mailgun: { authProvisionId: "apn_xxxxxxx" },
    list: "Mailing List",
    address: "Email Address",
  },
})
```

Docs: [Managed auth guide](https://pipedream.com/docs/connect/managed-auth/quickstart.md) · [Tools guide](https://pipedream.com/docs/connect/components.md)

## Actions (11)

### `mailgun-create-mailinglist-member` — Create Mailing List Member (Write)

Add to an existing mailing list. See the docs here

Full schema: https://pipedream.com/apps/mailgun/actions/create-mailinglist-member.md

### `mailgun-create-route` — Create Route (Write)

Create a new route. See the docs here

Full schema: https://pipedream.com/apps/mailgun/actions/create-route.md

### `mailgun-delete-mailinglist-member` — Delete Mailing List Member (Write)

Delete a mailing list member by address. See the docs here

Full schema: https://pipedream.com/apps/mailgun/actions/delete-mailinglist-member.md

### `mailgun-retrieve-mailinglist-member` — Get Mailing List Member (Read-only)

Retrieve a mailing list member by address. See the docs here

Full schema: https://pipedream.com/apps/mailgun/actions/retrieve-mailinglist-member.md

### `mailgun-list-mailinglist-members` — Get Mailing List Members (Read-only)

List all mailing list members. See the docs here

Full schema: https://pipedream.com/apps/mailgun/actions/list-mailinglist-members.md

### `mailgun-list-domain-options` — List Domain Name Options (Read-only)

Retrieves available options for the Domain Name field.

Full schema: https://pipedream.com/apps/mailgun/actions/list-domain-options.md

### `mailgun-list-domains` — List Domains (Read-only)

List domains in Mailgun. See the docs here

Full schema: https://pipedream.com/apps/mailgun/actions/list-domains.md

### `mailgun-list-list-options` — List Mailing List Options (Read-only)

Retrieves available options for the Mailing List field.

Full schema: https://pipedream.com/apps/mailgun/actions/list-list-options.md

### `mailgun-send-email` — Send Email (Write)

Send email with Mailgun. See the docs here

Full schema: https://pipedream.com/apps/mailgun/actions/send-email.md

### `mailgun-suppress-email` — Suppress Email (Write)

Add email to the Mailgun suppression list. See the docs here

Full schema: https://pipedream.com/apps/mailgun/actions/suppress-email.md

### `mailgun-verify-email` — Verify Email (Read-only)

Verify email address deliverability with Mailgun. See the docs here

Full schema: https://pipedream.com/apps/mailgun/actions/verify-email.md

## Triggers (11)

### `mailgun-new-bounce` — New Bounce (Instant) (Instant)

Emit new event when the email recipient could not be reached.

Full schema: https://pipedream.com/apps/mailgun/triggers/new-bounce.md

### `mailgun-new-click` — New Click (Instant) (Instant)

Emit new event when the email recipient clicked on a link in the email. Open tracking must be enabled in the Mailgun control panel, and the CNAME record must be pointing to mailgun.org. See more at the Mailgun User's Manual Tracking Messages section

Full schema: https://pipedream.com/apps/mailgun/triggers/new-click.md

### `mailgun-new-complaint` — New Complaint (Instant) (Instant)

Emit new event when the email recipient clicked on the spam complaint button within their email client. Feedback loops enable the notification to be received by Mailgun.

Full schema: https://pipedream.com/apps/mailgun/triggers/new-complaint.md

### `mailgun-new-delivery` — New Delivery (Instant) (Instant)

Emit new event when an email is sent and accepted by the recipient email server.

Full schema: https://pipedream.com/apps/mailgun/triggers/new-delivery.md

### `mailgun-new-delivery-failure` — New Delivery Failure (Instant) (Instant)

Emit new event when an email can't be delivered to the recipient email server.

Full schema: https://pipedream.com/apps/mailgun/triggers/new-delivery-failure.md

### `mailgun-new-log-data` — New Log Data (Polling)

Emit new event when new data is logged in Mailgun's Control Panel. Occurs for most actions within the associated Mailgun account.

Full schema: https://pipedream.com/apps/mailgun/triggers/new-log-data.md

### `mailgun-new-mailing-list` — New Mailing List (Polling)

Emit new event when a new mailing list is added to the associated Mailgun account.

Full schema: https://pipedream.com/apps/mailgun/triggers/new-mailing-list.md

### `mailgun-new-open` — New Open (Instant) (Instant)

Emit new event when the email recipient opened the email and enabled image viewing. Open tracking must be enabled in the Mailgun control panel, and the CNAME record must be pointing to mailgun.org. See more at the Mailgun User's Manual Tracking Messages section

Full schema: https://pipedream.com/apps/mailgun/triggers/new-open.md

### `mailgun-new-permanent-failure` — New Permanent Failure (Instant) (Instant)

Emit new event when an email can't be delivered to the recipient email server due to a permanent mailbox error such as non-existent mailbox.

Full schema: https://pipedream.com/apps/mailgun/triggers/new-permanent-failure.md

### `mailgun-new-temporary-failure` — New Temporary Failure (Instant) (Instant)

Emit new event when an email can't be delivered to the recipient email server due to a temporary mailbox error such as an ESP block. ESP is the Email Service Provider managing the recipient email server.

Full schema: https://pipedream.com/apps/mailgun/triggers/new-temporary-failure.md

### `mailgun-new-unsubscribe` — New Unsubscribe (Instant) (Instant)

Emit new event when the email recipient clicked on the unsubscribe link. Unsubscribe tracking must be enabled in the Mailgun control panel. See more at the Mailgun User's Manual Tracking Messages section

Full schema: https://pipedream.com/apps/mailgun/triggers/new-unsubscribe.md

---

- All apps: https://pipedream.com/apps — index: https://pipedream.com/llms.txt
- Pipedream docs for agents: https://pipedream.com/docs/llms.txt
