Mailhook - How to create?

Is possible to create a mailhook on n8n?

I want to be able to read all the emails that arrive and use it as tigger
the tool I use is very limited in relation to webhook, but it is possible to send any data via email
in the text of the email will be sent in json format, I don’t know if I’ll need to parse the json
But the first question is whether it is possible to have this “Read emails that arrive” trigger

Yes, that is already possible with this node:

Unfortunately that requires giving the IMAP node full access to all incoming mail, which is a huge compromise on security and privacy. See also this newer thread asking for a better solution: Mailhook Solution Solution (aside from IMAP node)

Welcome to the community @aspiers!

Yes, I can understand that you do not want to use your regular email address. In this case, would the simplest and most secure thing be to create a specific email account just for triggering workflows.

2 Likes

Thanks @jan! I discovered n8n very recently and it’s super awesome!

Creating a separate account for each mailhook and then having to set up separate IMAP credentials for each workflow still creates quite a lot of UX friction. Yes it’s workable, but I think it would be great if n8n could take a leaf out of the way make.com handles it, which is far far easier to set up.

I have submitted a feature request about this in a fresh thread, and just posted with a suggested architecture and possible no-code mockup which could be used as a proof of concept:

It isnt as nice as in make but if you need multiple emails you can ofcourse use something like gmail with the + in email adresses to create as many as you want with only 1 time setup. And then use the gmail node with a filter on the receive email adress including the +whatever addition you added to filter them out.
Hope this makes sense and gives you a work around for now.

If this feature isnt known to you here you go: Gmail Plus Addressing: The Hidden Feature that Can Help You Get More Out of Your Inbox | NC State Extension.

Yes I’m familiar with that trick. Although I don’t even need it as I run my own mail server, so <anything>@MYDOMAIN.org will get sent to me, so I already have the option of infinite inboxes.

I know that there are several workarounds which could work. However I’m much more interested in n8n supporting mailhooks natively, for the reasons I explained in Built-in mailhooks for triggering workflows by sending mail.

1 Like

If I may chime in here… SendGrid might have the solution you (and others) are looking for @aspiers

Sendgrid has a feature called Inbound Parse that allows you to create a custom subdomain for receiving inbound email (e.g. mailhook.mydomain.com). All email data sent to any address at that subd will be forwarded to the webhook that you provide. In your case, that would likely be a n8n Webhook, where you can thereafter use the Filter node in your workflow.

I have a paid sendgrid account which I believe is required for this feature. That’s worth a consideration here.

A tip…

I use a single workflow, and thus webhook, for similar processes, using the email ID (emailid@example.com) for distinction. An example might be [email protected] and [email protected]. Then, a Switch node in the workflow would send the JSON down the appropriate pathway.

Thanks, but as mentioned here I’m specifically looking to avoid third party services:

Similarly problematic is the suggestion to use a third-party mailhook service :

  • Those require substantial extra time to set up. Compare with the make.com solution above where it’s a single mouse click to create a new mailhook email address.
  • Those third party services are typically very expensive for this very small feature.
  • Again it requires sending email to yet another third party, which is a further compromise on security and privacy.

Your Switch node trick is essentially the same solution for routing which I referred to in the no-code mockup section of this post.

OK, I voted for your idea.

If you need a solution now, and cannot wait for it to be implemented directly into n8n, I suggest SengGrid, or going back to Make for that. In all honesty, the SendGrid setup wasn’t all that hard. Another alternative is using Zoho Mail as provider and setting up Outbound Webhooks in the settings menu. You can have rules-based webhooks that send the email data to any desired webhook.

Hi Aspiers,

I am moving some and potentially all services from Make to n8n. I am a heavy Make user with many complex scenarios. I came across your post after looking for a Mailhook node similar that in make.

It would obviously be great if there was a one for one mailhook node. But if I am honest I don’t see the issue with the imap node. It will be just as instant as a mailhook in Make. As others have mentioned you can setup a dedicated mailbox just for the imap connection. Then simply setup the forwarding rules as you do in Make. Then instead of having tons of different mailhook addresses like in Make, you just have the one address. All you need to do it setup a single filter for each app you want to pass, and decide how you are going to filter, lots of options in the replies.

Yes, it costs you a node step. But since n8n charges in full workflow executions, and not individual steps there really is no need to worry about having an extra node. Like you would in Make. If you run a local host you will also have unlimited workflow runs too.

Use cloudmailin. It’s free for the first 10.000 emails or so with max 512Kb per mail. Supwer easy to use and setup

Hey all,
same as @Rob we try to migrate big make scenarios now to n8n.

We’ve used the mailhook module in various of them.

I guess main problem to have a native integration within n8n will be the support of email service, what make.com ships with the mailhook - because make.com is cloud-hosted only, there is no problem maintaining it i guess.
But when it comes to self-hosted (as possible on n8n) by clients this could produce configuration issues - many different imap providers, different behaviours.

We use Mailjet in all of our transactional outbound communication and Mailjet also has a powerful parse api
https://dev.mailjet.com/email/guides/parse-api/

So the first tests with moved scenarios into workflows were successful.

cheers
Peter