Integrations
Email
Mailgun

How to send email with Mailgun

How to send transactional email notifications to Mailgun with Knock.

Knock integrates with Mailgun to send email notifications to your users. This page describes how to get started with Mailgun in Knock, including necessary provider configurations and additional data you can pass through to Mailgun.

Features

#
  • Attachments support
  • Delivery tracking
  • Bounce Support
  • Knock link and open tracking
  • Mailgun link and open tracking
  • Per environment configuration
  • Sandbox mode

Getting started

#

You can create a new Mailgun channel in the dashboard under the Channels and sources page in your account settings. From there, you'll need to configure the channel for each environment you have.

Channel configuration

#

The following channel settings should be configured per environment. Navigate to Channels and sources in your dashboard account settings, select your Mailgun channel, then click "Manage configuration" under the environment that you'd like to configure.

Fields marked with an * are required.

Knock settings

Sandbox modeboolean

Whether to enable sandbox mode for your Mailgun channel.

Knock open trackingboolean

Whether to enable Knock email-open tracking.

Knock link trackingboolean

Whether to enable Knock link-click tracking.

Provider settings for Mailgun

API keystring*

The private API key for your Mailgun account.

Domainstring*

The domain verified with Mailgun for sending emails.

Mailgun regionenum*

The sending region (US or EU) for your Mailgun account.

Open trackingboolean

Whether to enable Mailgun email-open tracking.

Link trackingboolean

Whether to enable Mailgun link-click tracking.

From email addressstring | liquid*

The default sender email address (can use Liquid tags).

From namestring | liquid

The default sender name (can use Liquid tags).

When configured, these optional overrides will apply to all emails sent from this channel in the configured environment. Learn more about email channel overrides here.

Tostring | liquid

The To email address that email notifications will be sent to (can use Liquid tags). This value will override the designated recipient's email address.

Ccstring | liquid

The CC email address that email notifications will be sent to (can use Liquid tags).

Bccstring | liquid

The BCC email address that email notifications will be sent to (can use Liquid tags).

Reply-tostring | liquid

The reply-to email address that will be included on email notifications (can use Liquid tags).

Payload overridesJSON (string) | liquid

Provide a JSON object to merge into the API payload that is sent to the downstream provider.

Set optional per-environment conditions for this channel. These conditions are evaluated each time a workflow run encounters a step that uses this channel in the configured environment. If the conditions are not met, the step will be skipped.

Additional data sent

#

Knock sends the following attributes to Mailgun along with your emails:

  • v:sender: always set to knock.app
  • v:knock_message_id: the ID of the message this email is associated with
  • v:knock_recipient_id: the Knock ID of the recipient this email is being sent to
  • o:tag: the workflow key for the workflow being invoked

You can learn about the role of these Mailgun attributes in the Mailgun API documentation.

Recipient data requirements

#

In order to send an email notification you'll need a valid email property set on your recipient.

Delivery status webhooks

#

When enabled, Mailgun will send delivery status updates directly to Knock via webhooks, allowing you to track the full lifecycle of your email messages in real-time.

Prerequisites

#

Before enabling delivery status webhooks, you need:

  1. A verified domain in Mailgun
  2. A Mailgun channel configured in Knock (see the getting started section above)
  3. Access to your Mailgun domain webhook settings

Setting up delivery status webhooks

#
1

Enable delivery status webhooks in Knock

  1. Navigate to Channels and sources in your Knock dashboard
  2. Select your Mailgun channel
  3. Click "Manage configuration" for the environment you want to configure
  4. Scroll to the "Incoming message status updates" section and enable incoming webhooks
  5. Copy the generated webhook URL - you'll need this in the next step
2

Configure webhooks in Mailgun

In the Mailgun dashboard, configure webhooks to send delivery events to Knock:

  1. Go to Sending > Webhooks in your Mailgun dashboard
  2. Select the domain you're using with Knock
  3. Add the webhook URL from Knock to these webhook types:
    • Delivered messages - Click "Add webhook URL", paste the Knock webhook URL, and save
    • Permanent failure - Click "Add webhook URL", paste the Knock webhook URL, and save
  4. Mailgun will automatically begin sending events to Knock

Supported delivery statuses

#

When delivery status webhooks are enabled for Mailgun, Knock will update message statuses based on these Mailgun webhook events:

Mailgun Event TypeKnock StatusDescription
delivereddeliveredThe email was successfully delivered to the recipient's mail server
failedbouncedThe email failed permanently due to invalid recipient or domain

Troubleshooting

#

If delivery status updates aren't appearing in Knock:

  1. Check webhook configuration. Verify both "Delivered messages" and "Permanent failure" webhooks are configured with the correct Knock webhook URL for your domain.
  2. Verify domain. Ensure you're sending from a verified domain in Mailgun that matches the domain configured in your webhooks.
  3. Check webhook region. Ensure your Mailgun region (US or EU) matches the region configured in your Knock channel settings.
  4. Test webhooks. Send a test email and check the Webhooks page in Mailgun to verify events are being sent.
  5. Review webhook logs. Check the webhook logs in Mailgun to see if requests are being sent successfully.

Passing additional tags to Mailgun

#

It's possible to pass additional tags to Mailgun by setting the "JSON overrides" attribute in the channel configuration or at the message template level.

To pass one or more tags, you can set the o:tag attribute to an array of tag names: