Mailgun API

Discover more about the Mailgun API connector and how to use it on the Digibee Integration Platform.

Mailgun API integrates with Mailgun’s email delivery service, allowing you to send emails with custom recipients, subjects, and content, including attachments. It helps automate notifications, transactional emails, and marketing messages within your pipelines.

Parameters

Take a look at the configuration parameters for the connector. Parameters supported by Double Braces expressions are marked with (DB).

General tab

Parameter
Description
Default value
Data type

Account

The account used by the connector. Supported type: Basic.

N/A

Account

Fail On Error

If the option is activated, the pipeline's execution with an error will be interrupted. Otherwise, the pipeline execution proceeds, but the result will show a false value for the "success" property.

False

Boolean

Host tab

Parameter
Description
Default value
Data type

Host (DB)

The base URL of the Mailgun API.

N/A

String

Path

The specific Mailgun endpoint to be accessed. The selected path may determine additional configuration options, such as query parameters. For details on each endpoint, refer to the Mailgun API documentation.

N/A

String

Method

The HTTP method used for the request.

N/A

String

Multi Part Data (DB)

Multi Part Data to be sent in the REST call.

N/A

JSON

Settings tab

Parameter
Description
Default value
Data type

Connect Timeout (ms)

Maximum time allowed for establishing a connection, in milliseconds.

30000

Integer

Read Timeout (ms)

Maximum time allowed for reading data, in milliseconds.

30000

Integer

Stop on Client Error

When enabled, stops the pipeline execution if a 4xx HTTP error occurs.

False

Boolean

Stop on Server Error

When enabled, stops the pipeline execution if a 5xx HTTP error occurs.

False

Boolean

Override Response Charset

When enabled, replaces the charset returned by the endpoint with the one specified in the Response Charset property. Otherwise, the charset from the Content-Type header is used.

True

Boolean

Response Charset

Defines the charset to be used when Override Response Charset is enabled. Default: UTF-8.

UTF-8

String

Documentation tab

Parameter
Description
Default value
Data type

Documentation

Section for documenting any necessary information about the connector configuration and business rules.

N/A

String

Usage examples

Sending an email

This connector allows you to send emails by specifying message components such as to, from, subject, HTML, and text parts. If you are using a free plan for testing purposes, you can only send emails to Authorized Recipients.

Required fields: The from, to, and subject fields must be included in the request body schema for the email to be sent successfully.

On the Digibee Integration Platform, you can send emails in two ways:

  • By passing the full body directly in the connector

  • By using Double Braces expressions

Passing the full body

Connector configuration

API tab:

  • Path: v3/{domain_name}/messages

  • Method: POST

  • Path {domain_name): sandbox1947004bd8a14996bc8610978bce37e7.mailgun.org

  • Header {Content-Type}: Multipart/form-data

  • Multi Part Data:

{
  "fields": {
    "from": "Mailgun Sandbox <[email protected]>",
    "to": "John Doe <[email protected]>",
    "subject": "Hello John",
    "text": "Congratulations John, you just sent an email with Mailgun! You are truly awesome!"
  }
}

Example response:

{
  "status": 200,
  "statusMessage": "",
  "body": {
    "id": "<20250318144251.422a1712bf6c5a4c@sandbox1947004bd8a14996bc8610978bce37e7.mailgun.org>",
    "message": "Queued. Thank you."
  },
  "headers": {
    "access-control-allow-credentials": "true",
    "access-control-allow-origin": "*",
    "account-id": "67d2d0ac0f6261b4526226e2",
    "cache-control": "no-store",
    "content-length": "126",
    "content-type": "application/json; charset=utf-8",
    "date": "Tue, 18 Mar 2025 14:42:51 GMT",
    "strict-transport-security": "max-age=63072000; includeSubDomains",
    "x-mailgun-key-id": "623424ea-c0c80f74",
    "x-ratelimit-limit": "80000",
    "x-ratelimit-remaining": "79999",
    "x-ratelimit-reset": "1742308981236",
    "x-recipient-limit": "2000000",
    "x-recipient-remaining": "1999999",
    "x-recipient-reset": "1742308981236",
    "x-server": "influx",
    "x-xss-protection": "1; mode=block"
  }
}
Using Double Braces expressions

To send an email using Double Braces expressions, you need to:

  1. Place a JSON Generator connector before the Mailgun API connector.

  2. Use the following JSON payload:

{
    "from": "Mailgun Sandbox <[email protected]>",
    "to": "John Doe <[email protected]>",
    "subject": "Hello!",
    "text": "Welcome to Digibee"
}

3. In the Mailgun API connector, configure:

API tab:

  • Path: v3/{domain_name}/messages

  • Method: POST

  • Path {domain_name): sandbox1947004bd8a14996bc8610978bce37e7.mailgun.org

  • Header {Content-Type}: Multipart/form-data

  • Multi Part Data:

{
  "fields": {
    "from": {{ message.from }},
    "to": {{ message.to }},
    "subject": {{ message.subject}},
    "text": {{ message.text }}
  }
}

Example response:

{
  "status": 200,
  "statusMessage": "",
  "body": {
    "id": "<20250319125318.152d650c9d0e220e@sandbox1947004bd8a14996bc8610978bce37e7.mailgun.org>",
    "message": "Queued. Thank you."
  },
  "headers": {
    "access-control-allow-credentials": "true",
    "access-control-allow-origin": "*",
    "account-id": "67d2d0ac0f6261b4526226e2",
    "cache-control": "no-store",
    "content-length": "126",
    "content-type": "application/json; charset=utf-8",
    "date": "Wed, 19 Mar 2025 12:53:18 GMT",
    "strict-transport-security": "max-age=63072000; includeSubDomains",
    "x-mailgun-key-id": "623424ea-c0c80f74",
    "x-ratelimit-limit": "80000",
    "x-ratelimit-remaining": "79999",
    "x-ratelimit-reset": "1742388808749",
    "x-recipient-limit": "2000000",
    "x-recipient-remaining": "1999999",
    "x-recipient-reset": "1742388808749",
    "x-server": "influx",
    "x-xss-protection": "1; mode=block"
  }
}

Attaching files to the email

You can attach one or more files to your email.

Single attachment

Add the attachment field to the JSON body, as shown below:

{
  "fields": {
    "from": "Mailgun Sandbox <[email protected]>",
    "to": "John Doe <[email protected]>",
    "subject": "Hello!",
    "html":"<h1>Hello</h1><p>This is the email content.</p>",
    "attachment": {{ message.fileName}}
  }
}
Multiple attachments

Each attachment must have a unique identifier while maintaining attachment as the base name. You can use variations such as attachmentPDF, attachment2, or attachment_2. See the example:

{
  "fields": {
    "from": "Mailgun Sandbox <[email protected]>",
    "to": "Digibee <[email protected]>",
    "subject": "Hello!",
    "html":"<h1>Hello</h1><p>This is the email content.</p>",
    "attachment": {{ message.fileName}},
    "attachment2": {{ message.fileName2}}
  }
}

Retrieving a paginated list of events

Mailgun tracks every inbound and outbound message event and retains this data for at least three days. You can retrieve a paginated list of these events.

For this example, we filter events of type delivered and opened.

Delivered events

Connector configuration

API tab:

Example response:

{
  "status": 200,
  "statusMessage": "",
  "body": {
    "items": [
      {
        "tags": [
          
        ],
        "delivery-status": {
          "first-delivery-attempt-seconds": 0.28,
          "attempt-no": 1,
          "mx-host": "aspmx.l.google.com",
          "tls": true,
          "utf8": true,
          "code": 250,
          "session-seconds": 1.066,
          "certificate-verified": true,
          "message": "OK",
          "enhanced-code": "",
          "description": ""
        },
        "id": "KEsUGyjdTJ602U6INUgxbA",
        "user-variables": {
          
        },
        "event": "delivered",
        "primary-dkim": "mx._domainkey.sandbox.mgsend.net",
        "flags": {
          "is-test-mode": false,
          "is-authenticated": true,
          "is-system-test": false,
          "is-routed": false
        },
        "message": {
          "size": 420,
          "headers": {
            "from": "Mailgun Sandbox <[email protected]>",
            "subject": "Hello!",
            "message-id": "20250318144251.422a1712bf6c5a4c@sandbox1947004bd8a14996bc8610978bce37e7.mailgun.org",
            "to": "John Doe <[email protected]>"
          },
          "attachments": [
            
          ]
        },
        "recipient": "[email protected]",
        "recipient-domain": "email.com",
        "log-level": "info",
        "recipient-provider": "Google Workspace",
        "envelope": {
          "targets": "[email protected]",
          "sender": "[email protected]",
          "sending-ip": "159.135.228.60",
          "transport": "smtp"
        },
        "campaigns": [
          
        ],
        "storage": {
          "region": "us-west1",
          "key": "BAABAQXGi0zYUlTqvp1H269ssre_PkBIYw",
          "env": "production",
          "url": "https://storage-us-west1.api.mailgun.net/v3/domains/sandbox1947004bd8a14996bc8610978bce37e7.mailgun.org/messages/BAABAQXGi0zYUlTqvp1H269ssre_PkBIYw"
        },
        "timestamp": 1742308972.4313374
      }
    ],
    "paging": {
      "previous": "https://api.mailgun.net/v3/sandbox1947004bd8a14996bc8610978bce37e7.mailgun.org/events/WzMseyJiIjoiMjAyNS0wMy0xOVQxMjozMDo0OC44ODMrMDA6MDAiLCJlIjoiMjAyNS0wMy0xOFQxMjozMDo0OC44OTIrMDA6MDAifSx7ImIiOiIyMDI1LTAzLTE4VDE0OjQyOjUyLjQzMSswMDowMCIsImUiOiIyMDI1LTAzLTE5VDEyOjMwOjQ4Ljg4MyswMDowMCJ9LCJfZG9jI0tFc1VHeWpkVEo2MDJVNklOVWd4YkEiLFsiZiIsInAiXSxudWxsLFtbImFjY291bnQuaWQiLCI2N2QyZDBhYzBmNjI2MWI0NTI2MjI2ZTIiXSxbImRvbWFpbi5uYW1lIiwic2FuZGJveDE5NDcwMDRiZDhhMTQ5OTZiYzg2MTA5NzhiY2UzN2U3Lm1haWxndW4ub3JnIl0sWyJldmVudCIsImRlbGl2ZXJlZCJdXSwxMDBd",
      "next": "https://api.mailgun.net/v3/sandbox1947004bd8a14996bc8610978bce37e7.mailgun.org/events/WzMseyJiIjoiMjAyNS0wMy0xOVQxMjozMDo0OC44ODMrMDA6MDAiLCJlIjoiMjAyNS0wMy0xOFQxMjozMDo0OC44OTIrMDA6MDAifSx7ImIiOiIyMDI1LTAzLTE4VDE0OjQyOjUyLjQzMSswMDowMCIsImUiOiIyMDI1LTAzLTE4VDEyOjMwOjQ4Ljg5MiswMDowMCJ9LCJfZG9jI0tFc1VHeWpkVEo2MDJVNklOVWd4YkEiLFsiZiJdLG51bGwsW1siYWNjb3VudC5pZCIsIjY3ZDJkMGFjMGY2MjYxYjQ1MjYyMjZlMiJdLFsiZG9tYWluLm5hbWUiLCJzYW5kYm94MTk0NzAwNGJkOGExNDk5NmJjODYxMDk3OGJjZTM3ZTcubWFpbGd1bi5vcmciXSxbImV2ZW50IiwiZGVsaXZlcmVkIl1dLDEwMF0=",
      "first": "https://api.mailgun.net/v3/sandbox1947004bd8a14996bc8610978bce37e7.mailgun.org/events/WzMseyJiIjoiMjAyNS0wMy0xOVQxMjozMDo0OC44ODMrMDA6MDAiLCJlIjoiMjAyNS0wMy0xOFQxMjozMDo0OC44OTIrMDA6MDAifSx7ImIiOiIyMDI1LTAzLTE5VDEyOjMwOjQ4Ljg4MyswMDowMCIsImUiOiIyMDI1LTAzLTE4VDEyOjMwOjQ4Ljg5MiswMDowMCJ9LG51bGwsWyJmIl0sbnVsbCxbWyJhY2NvdW50LmlkIiwiNjdkMmQwYWMwZjYyNjFiNDUyNjIyNmUyIl0sWyJkb21haW4ubmFtZSIsInNhbmRib3gxOTQ3MDA0YmQ4YTE0OTk2YmM4NjEwOTc4YmNlMzdlNy5tYWlsZ3VuLm9yZyJdLFsiZXZlbnQiLCJkZWxpdmVyZWQiXV0sMTAwXQ==",
      "last": "https://api.mailgun.net/v3/sandbox1947004bd8a14996bc8610978bce37e7.mailgun.org/events/WzMseyJiIjoiMjAyNS0wMy0xOVQxMjozMDo0OC44ODMrMDA6MDAiLCJlIjoiMjAyNS0wMy0xOFQxMjozMDo0OC44OTIrMDA6MDAifSx7ImIiOiIyMDI1LTAzLTE4VDEyOjMwOjQ4Ljg5MiswMDowMCIsImUiOiIyMDI1LTAzLTE5VDEyOjMwOjQ4Ljg4MyswMDowMCJ9LG51bGwsWyJmIiwicCJdLG51bGwsW1siYWNjb3VudC5pZCIsIjY3ZDJkMGFjMGY2MjYxYjQ1MjYyMjZlMiJdLFsiZG9tYWluLm5hbWUiLCJzYW5kYm94MTk0NzAwNGJkOGExNDk5NmJjODYxMDk3OGJjZTM3ZTcubWFpbGd1bi5vcmciXSxbImV2ZW50IiwiZGVsaXZlcmVkIl1dLDEwMF0="
    }
  },
  "headers": {
    "access-control-allow-credentials": "true",
    "access-control-allow-origin": "*",
    "cache-control": "no-store",
    "content-type": "application/json",
    "date": "Wed, 19 Mar 2025 12:30:48 GMT",
    "server": "TwistedWeb/22.10.0",
    "strict-transport-security": "max-age=63072000; includeSubDomains",
    "x-xss-protection": "1; mode=block"
  }
}
Opened events

Connector configuration

API tab:

Example response:

{
  "status": 200,
  "statusMessage": "",
  "body": {
    "items": [
      
    ],
    "paging": {
      "previous": "https://api.mailgun.net/v3/sandbox1947004bd8a14996bc8610978bce37e7.mailgun.org/events/WzMseyJiIjoiMjAyNS0wMy0xOVQxMjo1NTowNi4xMzMrMDA6MDAiLCJlIjoiMjAyNS0wMy0xOFQxMjo1NTowNi4xNDkrMDA6MDAifSx7ImIiOiIyMDI1LTAzLTE5VDEyOjU1OjA2LjEzMyswMDowMCIsImUiOiIyMDI1LTAzLTE5VDEyOjU1OjA2LjEzMyswMDowMCJ9LG51bGwsWyJmIiwicCJdLG51bGwsW1siYWNjb3VudC5pZCIsIjY3ZDJkMGFjMGY2MjYxYjQ1MjYyMjZlMiJdLFsiZG9tYWluLm5hbWUiLCJzYW5kYm94MTk0NzAwNGJkOGExNDk5NmJjODYxMDk3OGJjZTM3ZTcubWFpbGd1bi5vcmciXSxbImV2ZW50Iiwib3BlbmVkIl1dLDEwMF0=",
      "next": "https://api.mailgun.net/v3/sandbox1947004bd8a14996bc8610978bce37e7.mailgun.org/events/WzMseyJiIjoiMjAyNS0wMy0xOVQxMjo1NTowNi4xMzMrMDA6MDAiLCJlIjoiMjAyNS0wMy0xOFQxMjo1NTowNi4xNDkrMDA6MDAifSx7ImIiOiIyMDI1LTAzLTE5VDEyOjU1OjA2LjEzMyswMDowMCIsImUiOiIyMDI1LTAzLTE4VDEyOjU1OjA2LjE0OSswMDowMCJ9LG51bGwsWyJmIl0sbnVsbCxbWyJhY2NvdW50LmlkIiwiNjdkMmQwYWMwZjYyNjFiNDUyNjIyNmUyIl0sWyJkb21haW4ubmFtZSIsInNhbmRib3gxOTQ3MDA0YmQ4YTE0OTk2YmM4NjEwOTc4YmNlMzdlNy5tYWlsZ3VuLm9yZyJdLFsiZXZlbnQiLCJvcGVuZWQiXV0sMTAwXQ==",
      "first": "https://api.mailgun.net/v3/sandbox1947004bd8a14996bc8610978bce37e7.mailgun.org/events/WzMseyJiIjoiMjAyNS0wMy0xOVQxMjo1NTowNi4xMzMrMDA6MDAiLCJlIjoiMjAyNS0wMy0xOFQxMjo1NTowNi4xNDkrMDA6MDAifSx7ImIiOiIyMDI1LTAzLTE5VDEyOjU1OjA2LjEzMyswMDowMCIsImUiOiIyMDI1LTAzLTE4VDEyOjU1OjA2LjE0OSswMDowMCJ9LG51bGwsWyJmIl0sbnVsbCxbWyJhY2NvdW50LmlkIiwiNjdkMmQwYWMwZjYyNjFiNDUyNjIyNmUyIl0sWyJkb21haW4ubmFtZSIsInNhbmRib3gxOTQ3MDA0YmQ4YTE0OTk2YmM4NjEwOTc4YmNlMzdlNy5tYWlsZ3VuLm9yZyJdLFsiZXZlbnQiLCJvcGVuZWQiXV0sMTAwXQ==",
      "last": "https://api.mailgun.net/v3/sandbox1947004bd8a14996bc8610978bce37e7.mailgun.org/events/WzMseyJiIjoiMjAyNS0wMy0xOVQxMjo1NTowNi4xMzMrMDA6MDAiLCJlIjoiMjAyNS0wMy0xOFQxMjo1NTowNi4xNDkrMDA6MDAifSx7ImIiOiIyMDI1LTAzLTE4VDEyOjU1OjA2LjE0OSswMDowMCIsImUiOiIyMDI1LTAzLTE5VDEyOjU1OjA2LjEzMyswMDowMCJ9LG51bGwsWyJmIiwicCJdLG51bGwsW1siYWNjb3VudC5pZCIsIjY3ZDJkMGFjMGY2MjYxYjQ1MjYyMjZlMiJdLFsiZG9tYWluLm5hbWUiLCJzYW5kYm94MTk0NzAwNGJkOGExNDk5NmJjODYxMDk3OGJjZTM3ZTcubWFpbGd1bi5vcmciXSxbImV2ZW50Iiwib3BlbmVkIl1dLDEwMF0="
    }
  },
  "headers": {
    "access-control-allow-credentials": "true",
    "access-control-allow-origin": "*",
    "cache-control": "no-store",
    "content-type": "application/json",
    "date": "Wed, 19 Mar 2025 12:55:06 GMT",
    "server": "TwistedWeb/22.10.0",
    "strict-transport-security": "max-age=63072000; includeSubDomains",
    "x-xss-protection": "1; mode=block"
  }
}

Last updated

Was this helpful?