Exclude bulk of email providers

Hello, I want to exclude some emails that matchs the proviers that are in a list.
i.g : “test.com”, “hotmail.com

How to exclude users with specific email provider

Please share your workflow

The node is not filtering

It should output two branchs since i’m filtering on “@hotmail

Hi @TheG!

There’s two issues there with your expression - includes can’t take an array like you’ve provided, and it would need to be {{ $json.email.includes('@hotmail') }} on one expression, and using OR instead of AND (which you can change at the bottom of the if node under the “combine” dropdown") adding another case for @yopmail. Unfortunately your current expression is backwards :sweat_smile:

If you have a lot more emails to add for exclusion, you might want to take care of this instead in a code node, which would look like this:

Let me know if that helps!

1 Like

You can also do this with a small tweak to your current expression: by extracting the domain from the email first:

{{ ['hotmail.com', 'gmail.com'].includes($json.email.extractDomain()) }}

Example workflow


I fianally used this piece of code :

// PRoviders to exclude
const excludedEmailProviders = [

function getEmailDomain(email) {
  return email.split('@')[1].split('.')[0];

function filterUsersByExcludedEmailProviders(users, excludedProviders) {
  return users.filter((user) => {
    const emailDomain = getEmailDomain(user.email);
    return !excludedProviders.includes(emailDomain);

// Get input data from the previous node
const userData = items.map((item) => item.json);

const filteredUsers = filterUsersByExcludedEmailProviders(userData, excludedEmailProviders);

// Set output data for the next node
return filteredUsers.map((user) => ({ json: user }));

I tried your solution and it works well and much easier, thanks