N8N – Integration with Mailtrap
You can now seamlessly integrate Mailtrap’s email delivery and testing services into your N8N workflows, as well as easily manage your contacts.
And, in this article, I’ll show you how to:
- Install Mailtrap node and set up N8N
- Obtain Mailtrap API credentials
- Integrate N8N with Mailtrap
Note: If you want to use this integration to send emails, you first need to set up your sending domain. If you haven’t, do it before we start—it takes ~5 minutes, and you can use our step-by-step article as a guide.
N8N Cloud
If you are a user of n8n Cloud, you can have access to Mailtrap integration out of the box.
Just search for "Mailtrap" in the nodes.
Local N8N setup
To install Mailtrap node, you can simply type in n8n-nodes-mailtrap
under ‘Enter npm package name’ in Community Nodes, just like so:
Or, you can run use npm to install the node manually:
npm install n8n-nodes-mailtrap
Next, simply create a free N8N account:
Obtain Mailtrap API credentials
Whether you want to only create contacts or send/test emails via Mailtrap x N8N, you’ll first need a Mailtrap API token and Mailtrap Account ID. To obtain one, follow these steps:
- Go to Settings on the left side-bar menu, navigate to API Tokens, and click on Add Token.
- Enter the desired name, click on Add Token, tick the desired permission checkboxes, and hit Save.
- Copy the token and save it in a secure place.
- Lastly, to obtain the Account ID, go to Settings → Account Settings → Account Details.
Integrate N8N with Mailtrap
Step 1. Select Mailtrap
- When you open your N8N dashboard, click on the left card ‘Start from scratch’
- Then, click on the ‘Add first step…’
- On the right-side menu, type ‘Mailtrap’ in the search bar, click on it, and select which actions you want to automate (e.g., sending an email, creating/updating contacts, etc.)
Here’s an example workflow I created for the purposes of this demo:
Step 2. Enter your Mailtrap credentials
- In the parameters window, click on ‘Select Credential’ and ‘+ Create new credential’ to add the credentials we obtained in the previous chapter.
- In the credentials setting, simply add the API Token and Mailtrap Host.
Important: Keep in mind that I’ve added my Sending credentials (send.api.mailtrap.io). You can also use your Sandbox credentials if you want to test your emails instead.
- Then, back in the Parameters window, add the account ID.
Step 3. Test the integration
- Lastly, simply click on ‘Test step’ to test the integration:
Now, every time a new user logs in and updates their name, they will get a confirmation email via Mailtrap and their information will be logged in my Mailtrap Contacts Page. There, I can group them into lists, segment them accordingly, and use Fields to personalize my email campaigns further.