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.
Additional data sent
#Knock sends the following attributes to Mailgun along with your emails:
v:sender: always set toknock.appv:knock_message_id: the ID of the message this email is associated withv:knock_recipient_id: the Knock ID of the recipient this email is being sent too: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:
- A verified domain in Mailgun
- A Mailgun channel configured in Knock (see the getting started section above)
- Access to your Mailgun domain webhook settings
Setting up delivery status webhooks
#Supported delivery statuses
#When delivery status webhooks are enabled for Mailgun, Knock will update message statuses based on these Mailgun webhook events:
Troubleshooting
#If delivery status updates aren't appearing in Knock:
- Check webhook configuration. Verify both "Delivered messages" and "Permanent failure" webhooks are configured with the correct Knock webhook URL for your domain.
- Verify domain. Ensure you're sending from a verified domain in Mailgun that matches the domain configured in your webhooks.
- Check webhook region. Ensure your Mailgun region (US or EU) matches the region configured in your Knock channel settings.
- Test webhooks. Send a test email and check the Webhooks page in Mailgun to verify events are being sent.
- 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: