Skip to content

Label and filter Gmail threads using basic RegEx against the email body or headers.

License

Notifications You must be signed in to change notification settings

johnagan/gmail-labeler

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 

Repository files navigation

Gmail Labeler

Label and filter Gmail threads using basic RegEx against the email body or headers.

Configuration

Filters Options

var filters = [
  // star emails deliveredto user@domain.com
  { name: 'user emails', match: /deliveredto:user@domain.com/, star: true },
  
  // organize by list name
  { match: /(?:List-ID:\s(.+?)\s<)/, archive: true },

  // label all emails with "bank" in the subject as "finance" and mark as read
  { name: 'finance', subject: 'bank', markRead: true },
];
  • name - The label name to apply when matched. This can also be nested by adding slashes folder/name. If no name is set, it will use the first RegEx selector result (.+?)
  • match - The RegEx to match against. This searches the entire raw contents of the email, including the header. Include a RegEx selector to return dynamic label names (.+?)
  • subject - Helper to search the subject for text
  • archive - true/false to archive the matching emails
  • star - true/false to star the matching emails
  • markRead - true/false to mark the matching emails as read

From

var from = [
  "from:email@domain.com",
  "list:subscription.domain.com"
];

This can be any combination of Gmail filters to apply the labels against.

Installation

You'll need to enable Google App Scripts in your Google Drive account

Create a new Google App Script

Paste the labeler.gs contents into the new file and Save

After savings, create a new trigger

Run the labeler function every minute

About

Label and filter Gmail threads using basic RegEx against the email body or headers.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published