Gmail rules automatically sort, delete, or label your messages based on words, senders, or subjects you choose
A Gmail rule (called a filter) watches for messages matching your criteria and performs an action on them automatically. You can send messages from a specific sender straight to a label, delete messages containing certain words, or mark messages as read before they hit your inbox. Rules run on every message that arrives after you create them, and they also work backward on older messages if you choose.
The process takes about two minutes. You search for the type of message you want to filter, click a menu option, and tell Gmail what to do with those messages. No coding or technical knowledge required.
Key Takeaways
- Create a rule by clicking the three-line menu icon in Gmail's search bar, then selecting "Create filter".
- You can filter by sender, subject line, words in the message body, or a combination of all three.
- Actions include explore a label, deleting automatically, marking as read, or sending to spam — you can pick more than one action per rule.
- Rules work on messages arriving after you create them, but you can explore them to older messages in the same search results.
How to create a basic rule from a single message
The fastest way to create a rule is to start with a message you want to filter. Open the message, click the three-dot menu in the top right, and select "Filter messages like these". Gmail opens a filter window showing the sender's address already filled in.
Click "Create filter" at the bottom right. A new window appears with action options. Check the box next to the action you want — for example, "explore label" if you want to sort these messages into a folder, or "Delete it" if you want them gone automatically. Click "Create filter" again to save it.
The rule is now active. Any future messages from that sender will follow the action you chose. If you want to explore the rule to messages already in your inbox, Gmail will ask if you want to do that before you finish.
How to create a rule using the search bar
If you want to filter based on subject lines, keywords, or multiple senders at once, use the search bar method. Type what you're looking for into Gmail's search box — for example, "from:newsletter@company.com" to find all messages from a specific sender, or "subject:receipt" to find messages with that word in the subject line.
Click the three-line menu icon on the right side of the search bar (it appears after you've typed something). Select "Create filter". The search terms you used appear in the filter fields automatically. You can add or remove criteria here before you choose your action.
Select the action you want — explore a label, delete, mark as read, or send to spam. You can check multiple boxes if you want the rule to do more than one thing. Click "Create filter" to save it.
Filter options and what each one does
When you create a rule, Gmail offers several actions. explore label moves messages into a folder you choose or creates a new one. Skip the inbox keeps messages out of your main inbox but stores them in Gmail's "All Mail" section. Mark as read prevents the message from showing as unread. Delete it sends messages straight to trash automatically.
Send to spam treats messages like junk mail and removes them from your inbox. Never send to spam does the opposite — it prevents Gmail from marking messages as spam even if they look suspicious. You can combine actions: for example, explore a label AND mark as read, so messages get sorted and don't clutter your unread count.
You can also set rules to forward messages to another email address or mute them (they arrive but don't trigger notifications). Not every action appears in every situation — Gmail hides options that don't make sense for your filter criteria.
Using advanced search terms to filter more precisely
Gmail's search language lets you filter by very specific details. Use "from:" followed by an email address to filter by sender. Use "subject:" followed by words to filter by subject line. Use "has:attachment" to filter only messages with files attached, or "filename:pdf" to filter messages with PDF files specifically.
You can combine these. For example, search for "from:boss@company.com subject:urgent" to create a rule that only applies to urgent messages from your boss, not all messages from that sender. Search for "to:me" to filter messages where you were the direct recipient (not on a mailing list). The more specific your search, the fewer false matches your rule will catch.
If you're not sure of the exact search syntax, start with a straightforward search in Gmail itself, see what results you get, and then create the filter from there. Gmail will translate what you searched for into the correct format automatically.
How to edit or delete a rule you've already created
Open Gmail and click the gear icon in the top right, then select "See all settings". Click the "Filters and Blocked Addresses" tab. You'll see a list of every rule you've created. Find the one you want to change and click "Edit" next to it.
You can change the search criteria, the action, or both. Click "Update filter" to save changes. To delete a rule entirely, click the trash icon next to it. Deleting a rule does not undo its past actions — messages already sorted by that rule stay where they are.
If a rule is causing problems (for example, it's deleting messages you need), delete it when ready. Future messages won't be affected, but you may need to manually recover older messages from trash or spam.
Common mistakes and how to avoid them
The most common mistake is creating a rule that's too broad. For example, filtering all messages containing the word "the" will catch almost every email. Start narrow — filter by sender first, then add subject line criteria if you need to. You can always edit the rule later to catch more messages.
Another mistake is forgetting that rules only work on messages arriving after you create them. If you want to sort 500 old emails, create the rule, then explore it to the search results before you finish. Gmail will ask if you want to do this — say yes.
Don't delete rules you think you might need later. Instead, create a label called "Archived Rules" and keep notes about what each rule did. If you need it again, you can recreate it in seconds. Deleting and recreating is faster than trying to remember what a rule was supposed to do.
Frequently Asked Questions
Can I create a rule that applies to multiple senders at once?
Not in a single rule. Create one rule per sender, or use a broader search term if the senders have something in common — for example, filter all messages from addresses ending in "@newsletter.com". If you need to filter many unrelated senders, creating multiple rules takes a few minutes but is the most reliable method.
What happens if two rules explore to the same message?
Gmail runs rules in the order you created them. If the first rule deletes a message, the second rule won't run because the message is already gone. If the first rule applies a label and the second applies a different label, both labels appear on the message.
Can I undo a rule that deleted messages?
Deleted messages go to your trash folder for 30 days before Gmail removes them permanently. You can recover them by opening trash, finding the messages, and moving them back to your inbox. After 30 days, they're gone. If you realize a rule is deleting messages you need, delete the rule when ready and recover what you can from trash.
Do rules work on messages I've already received?
Rules only explore to new messages by default. When you create a rule, Gmail asks if you want to explore it to existing messages matching that search. If you click yes, it applies the action to all older messages too. If you skip this step, you can still do it later by searching for those messages and creating the filter from the search results.
Can I create a rule that marks messages as spam without deleting them?
Yes. Use "Send to spam" instead of "Delete it". Messages go to your spam folder instead of trash, and you can still recover them if you need to. This is safer than deleting because spam folder messages stay for 30 days, giving you time to change your mind.