How to filter incoming e-mail messages by IP address

This article describes how to use cPanel's e-mail filtering capabilities to process incoming messages from a specific IP address or range of IP addresses. For example, you may want to automatically delete all incoming messages from an IP address.

You can enable filtering for a specific user, or for all users on your account.

Determining which IP address to filter

All e-mail messages contain in their headers information about their origin. By examining the message headers, you can determine which IP address or addresses you want to filter.

For information about how to view e-mail message headers for your e-mail client, please see this article.

In the raw e-mail message headers, look for the IP address that you want to filter. The IP address is often in the Received: header.

Setting up the e-mail filter

After you know which IP address or addresses you want to filter, you are ready to set up filtering in cPanel. To do this, follow these steps:

  1. Log in to cPanel.
    If you do not know how to log in to your cPanel account, please see this article.
  2. Select one of the following:
    • If you want to filter messages by IP address for all of your e-mail accounts, in the EMAIL section of the cPanel home screen, click Global Email Filters:

      cPanel - Email - Global Email Filters icon

    • If you want to filter messages by IP address for a specific e-mail account, in the EMAIL section of the cPanel home screen, click Email Filters:

      cPanel - Email - Email Filters icon

      Locate the account for which you want to add a filter, and then click Manage Filters.

  3. Click Create a New Filter.
  4. In the Filter Name text box, type a name for the filter.
  5. Under Rules, in the From list box, select Any header.
  6. In the contains list box, select matches regex.
  7. In the next text box, type the following regular expression (also known simply as a “regex”). Replace xxx with the digits of the specific IP address you want to filter:


    Alternatively, you can filter a range of IP addresses. For example, the following regular expression matches the last 256 addresses in the network:

    A range of IP addresses is a collection defined by a starting address and ending address. For example, the range of IP addresses from to includes 75 total addresses.
    Make sure that the regular expression is not too broad. Otherwise, you may unintentionally filter messages that you want to receive. To test your regular expression interactively and make sure it matches what it is supposed to match, please visit
  8. Under Actions, select what to do with messages that match the filter. For example, you can discard the message, send it to a specific folder, redirect it, and other actions.
  9. Click Create. cPanel creates the new filter, which takes effect immediately.

More Information

For more information about IP addressing, please visit

Did you find this article helpful? Then you'll love our support. Experience the A2 Hosting difference today and get a pre-secured, pre-optimized website. Check out our web hosting plans today.

Usamos cookies con el fin de personalizar para usted nuestro sitio Web y analizar el uso de éste. Usted acepta esto haciendo clic en “Acepto” o al continuar usando el sitio Web. Hay más información sobre cookies en nuestra política de privacidad.