Filter Emails from People Not in your Contacts in Gmail

Gmail doesn’t support filtering or for that matter blocking emails from people not in your contact list. That is to mean, should your email address get in the hands of some unscrupulous entities, your poor inbox stands to get bombarded with spam or worse, phishing attacks.

This is a much needed feature that seems to have escaped Google despite its obvious security benefits.

Recently I came across a stranger with this predicament and out of curiosity I wondered whether it would be possible to accomplish that using Gmail’s Filter options.

So for the better part of today I’ve been playing around with various filter settings and I seem to have chanced upon a capable workaround: rather than filter emails of those not in your contacts, whitelist the existing contacts instead.

To do that we need to create a filter that will allow only emails from your existing Google contacts to reach your inbox while the rest will be sent to the trash (deleted), archived, forwarded etc. as they arrive.

Sounds good doesn’t it? Let’s see how to do it then. Be warned though, much of this will be done manually so be prepared to set some time apart, especially if you’ve a huge contact list.

Step 1: Select Contacts to Whitelist

1. Log in to your Gmail Account. Switch to Google Contacts by clicking on the small arrow beside the Gmail heading on the top left of the page.

switch to contacts
Switch to Google Contacts

2. Inside Google contacts select the contacts you’d wish to receive emails from. If it’s all of them, select one then at the top select the checkmark to select all.

select contacts
Select Contacts

3. On the top right click on the Mail icon so that it seems we’re sending an email to all the selected contacts.

send mail
Sending Email


  • If some of the contacts have phone numbers only, Gmail will just ignore them and only add those with valid email addresses.

4. That will open a pop up window to compose a message in the Gmail email editor.

email recipients
Email Recipients

All the selected Contacts’ email addresses will have been added inside the To box and now we need to copy all of them. To do that, click anywhere inside that box and press Ctrl + A. Now open a text editor like notepad and paste the email addresses there.

After that you can close the pop up window.

Step 2: Create a Filter to Block Emails

5. Go back to Gmail and open its Settings and select the Filters and blocked addresses tab. At the click open the Create a new filter link.

create filter
Create a New Filter

6. That should open a small Filter window at the bottom of the Search bar. Here now comes the tasking part.

From the copied email addreses we need to create a search term in the following format:

from:([email protected] OR [email protected] OR [email protected] OR [email protected])


  • The OR operator has to be in caps. Also don’t forget to include the from part since it’s what indicates that the terms are in fact email addresses.

So take your time and create that list. If you’ve a handful of contacts, it shouldn’t take you that long. I suppose this can be automated, but that’s well beyond my scope.

7. Once you’ve your contacts in the search term, paste it inside the Doesn’t have box.

filter email addresses
Add  Email Addresses to the Filter

To preview which emails would be blocked by this filter, click on the search button. All the emails not in you contact list should appear.

You can also do the opposite to confirm that emails only from your contacts will be allowed. To do that paste the search term inside the From box at the top instead of the Doesn’t have box, then preview the results.

8. Once you’re done, click on the small arrow on the end search bar to restore the filter window. Next click on the Create filter with this search link at the bottom right of the filter window.

9. Now decide how you’d want all the emails not from your contacts to be handled. The obvious choices here are to have them either Skip the Inbox or to Delete them.

filter options
Edit Filter Options

With Skip the Inbox they won’t show up in the inbox and instead will be archived as the moment they arrive. The archived emails can be accessed from the All Mail label (not the [Imap]/Archive).

all mail label
All Mail Label

If you chose to Delete them, they will be sent to the trash Bin automatically. As usual, they’ll be deleted completely if they stay in the Bin for more than 30 days.

10. If you want the existing emails not from your contacts to be applied that filter, put a check mark on the Also apply filter to matching messages.

11. Click on the Create filter button to finish. The filter should be created and can be edited at any time by going to Filters and blocked addresses settings. You can also export this filter and import it in other Gmail Addresses.

active filter
Active Filter

So now any email address that’s not in the contact list we’ve defined in that filter won’t show up in your inbox.


If you happen to get a new contact that you’d wish to allow, just edit this filter by adding their email address to the search term inside the Doesn’t have box then update the filter (don’t forget to add the OR operator).

You can also delete the filter anytime should you wish to stop filtering out the non-contacts from your inbox.

I know this is not the most intuitive way to do this, but in the meanwhile I hope it meets your needs. To submit this feature request, you can leave Google a feedback in Gmail by going to the Settings gear > Send Feedback. Perhaps if many people request it, they may just implement it.


Kelvin Muriuki is a web content developer that's passionate about keeping the internet a useful place. He is the founder and editor of Journey Bytes, a tech blog and web design agency. Feel free to connect with him regarding the content appearing on this page or on web and content development.


Leave a Reply

Feel free to share your comments or questions with me. I may not be able to respond immediately so please check later once I've approved your comment.

Your email address will not be published. Required fields are marked *