· Dan · ConnectWise  · 2 min read

Process Incoming Email with Mailgun

n8n-nodes-base.webhook @mspcopilot/n8n-nodes-connectwise.connectWisePsa

How to parse inbound email with Mailgun and action it with tickets or other integrations.

Overview

Did you know Mailgun can also process inbound emails? You can have Mailgun send directly to an n8n webhook for processing of emails.

The Workflow

Setup Instructions

I recommend setting up a dedicated subdomain for receiving alerts. Something like alerts.yourmsp.com.

Additionally, you could setup a single webhook in n8n to process the majority of your smaller alert emails like in the example below where we intercept emails from Addigy to create tickets.

Mailgun Route Settings

  1. In Mailgun, navigate to Send > RECEIVING > Routes.
  2. Add a new new route.
  3. Set Expression type to Match Recipient and enter something with a wildcard, such as alerts.*@alerts.yourmsp.com. You can be more specific, or use advanced rules using these filters.
  4. Enable Forward.
  5. Copy your n8n Webhook URL and paste it in the Destination text field.
  6. Enable Stop.
  7. Enter a reasonable description, or even put a link to your n8n workflow.

Recommendations

  • Add a descriptive string to the end of your Webhook URLs to make it easier to keep track of. Example: https://n8n.yourmsp.com/webhook/75b81103-bb6c-517d-8c0c-2dfd45f155581-mailgun-alerts.
  • Always have an Execution Data node to help with troubleshooting and logging later.
  • The webhook in the example is set to Respond When Last Node Finishes. This will cause an error message to be sent back to Mailgun if the workflow fails, causing it to retry. If this isn’t desired, turn it off.
Share: