{"id":16649217,"url":"https://github.com/rcmdnk/gmail_filter_manager","last_synced_at":"2025-10-07T11:30:58.480Z","repository":{"id":152345054,"uuid":"139768603","full_name":"rcmdnk/gmail_filter_manager","owner":"rcmdnk","description":"Tools to convert gmail's mailfilters.xml to yaml, and convert yaml to xml.","archived":false,"fork":false,"pushed_at":"2024-05-23T00:31:30.000Z","size":40,"stargazers_count":10,"open_issues_count":2,"forks_count":1,"subscribers_count":3,"default_branch":"master","last_synced_at":"2024-05-23T00:33:03.861Z","etag":null,"topics":["cli","gmail","python","python3"],"latest_commit_sha":null,"homepage":"https://pypi.org/project/gmail-filter-manager/","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/rcmdnk.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2018-07-04T21:50:35.000Z","updated_at":"2024-06-21T20:46:21.767Z","dependencies_parsed_at":null,"dependency_job_id":"6a558afe-bb23-4d25-af7b-41915c986f88","html_url":"https://github.com/rcmdnk/gmail_filter_manager","commit_stats":null,"previous_names":[],"tags_count":5,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rcmdnk%2Fgmail_filter_manager","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rcmdnk%2Fgmail_filter_manager/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rcmdnk%2Fgmail_filter_manager/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rcmdnk%2Fgmail_filter_manager/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/rcmdnk","download_url":"https://codeload.github.com/rcmdnk/gmail_filter_manager/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":235621547,"owners_count":19019520,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["cli","gmail","python","python3"],"created_at":"2024-10-12T09:08:02.904Z","updated_at":"2025-10-07T11:30:53.164Z","avatar_url":"https://github.com/rcmdnk.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# gmail_filter_manager\n\nGmail filer manager using YAML format.\n\n## Installation\n\nBy pip:\n\n```\n$ pip install gmail_filter_manager\n```\n\nBy Homebrew:\n\n```\n$ brew install rcmdnk/rcmdnkpac/gmail_filter_manager\n```\n\nBy script:\n\n```\n$ curl -fsSL https://raw.github.com/rcmdnk/gmail_filter_manager/install/install.sh| sh\n```\n\nThis will install scripts to `/usr/bin`\nand you may be asked root password.\n\nIf you want to install other directory, do like:\n\n```\n$ curl -fsSL https://raw.github.com/rcmdnk/gmail_filter_manager/install/install.sh|  prefix=~/usr/local/ sh\n```\n\nOr, simply download scripts in bin/ and place where you like.\n\nIf you use the script directly, you need to install ruaml.yaml:\n\n```\n$ pip install ruamel.yaml\n```\n\n## Scripts\n\n### gfm_extract\n\nA script to convert mailFilters.xml, which can be exported from Gmail,\nto YAML format.\n\nDefault input name is **mailFilters.xml**.\nDefault ouput name is **mailFilters.yaml**.\n\nThey can be changed by arguments:\n\n```\n$ gfm_extract [input name [output name]]\n```\n\nOnce you have YAML file,\nyou can edit it and use it as an input for `gfm_make`.\n\n### gfm_make\n\nA script to make XML of filters to be imported in Gmail.\n\nInput is YAML format.\n\nDefault input name is **mailFilters.yaml**.\nDefault ouput name is **mailFilters.yaml**.\n\n```yaml\nfilters:\n- from: \"foo@example.com\"\n  lable: \"foo\"\n- subject: \"[test]\"\n  lable: \"test\"\n  shouldMarkAsRead: \"true\"\nnamespaces:\n  apps: http://schemas.google.com/apps/2006\n  atom: http://www.w3.org/2005/Atom\n```\n\n**namespaces** can be omitted.\nIt is included if you use `gfm_extract`,\nbut it will be automatically added by `gfm_make` even if is omitted.\n\n## Filter properties\n\n### Filter Criteria Properties\n\n| Name                | XML attribute             | Description                                                                                                 |\n| :------------------ | :------------------------ | :---------------------------------------------------------------------------------------------------------- |\n| From                | name=\"from\"               | The email comes from this address.                                                                          |\n| To                  | name=\"to\"                 | The email is sent to this address.                                                                          |\n| Subject             | name=\"subject\"            | The email's title includes this value.                                                                      |\n| Has the words       | name=\"hasTheWord\"         | The email has this value (search operators).                                                                |\n| Doesn't have        | name=\"doesNotHaveTheWord\" | The email doesn't have this value (search operators).                                                       |\n| Has attachment      | name=\"hasAttachment\"      | true or false for if the email has attachments.                                                             |\n| Don't include chats | name=\"excludeChats\"       | true or false for if the email includes chats.                                                              |\n| Size                | name=\"size\"               | The email size. If it is specified, the mail size is compared to this value with sizeOperator and sizeUnit. |\n| Size operator       | name=\"sizeOperator\"       | s_sl (greater than) or s_ss (smaller than).                                                                 |\n| Size unit           | name=\"sizeUnit\"           | Unit of email size: s_sb (B), s_skb (kB) or s_smb (MB).                                                     |\n\n**hasTheWord** and **doesNotHaveTheWord** are search operators.\nSuch a label can be specified here.\n\nPlease check following help for more details:\n\n\u003e [Search operators you can use with Gmail - Gmail Help](https://support.google.com/mail/answer/7190)\n\n### Filter Action Properties\n\n| Name                        | XML attribute                      | Description                                                                                                                                         |\n| :-------------------------- | :--------------------------------- | :-------------------------------------------------------------------------------------------------------------------------------------------------- |\n| Skip the Inbox (Archive it) | name=\"shouldArchive\"               |                                                                                                                                                     |\n| Mark as read                | name=\"shouldMarkAsRead\"            |                                                                                                                                                     |\n| Star it                     | name=\"shouldStar\"                  |                                                                                                                                                     |\n| Apply the label             | name=\"label\"                       |                                                                                                                                                     |\n| Forward it to               | name=\"forwrdTo\"                    |                                                                                                                                                     |\n| Delete it                   | name=\"shouldTrash\"                 |                                                                                                                                                     |\n| Never send it to Spam       | name=\"shouldNeverSpam\"             |                                                                                                                                                     |\n| Always mark it as important | name=\"shouldAlwaysMarkAsImportant\" |                                                                                                                                                     |\n| Never mark it as important  | name=\"should                       |                                                                                                                                                     |\n| Categorize as               | name=\"smartLabelToApply\"           | Add smart label. value can be \"^smartlabel_personal\", \"^smartlabel_social\", \"^smartlabel_promo\", \"^smartlabel_group\" or \"^smartlabel_notification\". |\n\nTips:\n\nYou can use array for **label** to set several labels on the same criteria.\n\n## How to export/import filters\n\nCheck **Export or import filters** in the official help:\n\n\u003e [Create rules to filter your emails - Gmail Help](https://support.google.com/mail/answer/6579)\n\n## Filter Tips\n\n### Numbering labels\n\nGmail's labels are sorted automatically.\n\nBut you may want to put some labels such **Work**, which is always at the bottom,\non the top.\n\nTo do it, you can set prefix numbers on labels.\n\n- 01_Work\n- 02_Private\n- 03_Others\n\nThen, these labels are listed in this order.\n\n### Use labels like folder\n\nGmail has only **label**, but some other mail clients have **folder**.\n\n- Label: User can set several labels on the same message.\n- Folder: A message is included only in one folder.\n\nAnd all filters are always applied to the new mail.\n\nIn this case, if the mail is caught by several filters for labels,\nseveral labels are set.\n\nTo avoid several labels to use it as **folder**,\n**has:nouserlabels** keyword is useful.\n\nIf **hasTheWord** includes this keyword,\nonly the mail which still does not have the label can be caught.\n\ne.g.)\n\n```\nfilters:\n- hasTheWord: \"from:foo@example.com\"\n  label: \"00_foo\"\n- hasTheWord: \"has:nouserlabels from:example.com\"\n  label: \"01_example\"\n  shouldArchive: \"true\"\n- hasTheWord: \"has:nouserlabels\"\n  label: \"09_others\"\n  shouldArchive: \"true\"\n```\n\nThese filters put a label **foo** for mails from **foo@example.com**,\nand put a label **example** for mails from **example.com** domain other than **foo@example.com**.\nIn addition, if it is not from **foo**, the mail is archived.\n\nAnd the last filter send other mails to **others** label,\nand skip the Inbox.\nSuch a filter make you free from notification bombs\nin the Gmail app of a cell phone.\n\nTo use such filters, the order is important.\n\nNote: If you modify filters in the Gmail web interface,\nthe order is changed: the modified one goes to the bottom.\n\nThis is one of the reasons why I wanted these scripts.\n\n### Use DummyInbox to leave only specific mails in the Inbox\n\nYou may have more labels with which mails must skip the Inbox.\n\nIn this case, **DummyInbox** method label can be used instead of\nsetting **shouldArchive: \"true\"** for filters.\n\nThe setting is like this:\n\n```\nfilters:\n- hasTheWord: \"from:foo@example.com\"\n  label:\n  - \"00_foo\"\n  - \"99_DummyInbox\"\n- hasTheWord: \"from:example.com\"\n  label:\n  - \"01_example\"\n  - \"99_DummyInbox\"\n- hasTheWord: \"from:example2.com\"\n  label: \"02_example2\"\n- hasTheWord: \"from:example3.com\"\n  label: \"03_example3\"\n- hasTheWord: \"from:example4.com\"\n  label: \"04_example4\"\n- hasTheWord: \"from:example5.com\"\n  label: \"05_example5\"\n- hasTheWord: \"has:nouserlabels\"\n  label: \"09_others\"\n- hasTheWord: \"-label:99_DummyInbox\"\n  shouldArchive: \"true\"\n```\n\nThis setting put additional **99_DummyInbox** label\nto which you want to remain in the Inbox.\n\nAnd the final filter archives mails without **99_DummyInbox** label.\n\nIn the above setting, **has:nouserlabels** is not used for **from:example.com**.\nTherefore the mail from **foo@example.com** has two labels.\n\nThe main difference from\n[Use labels like folder](https://github.com/rcmdnk/gmail_filter_manager#use-labels-like-folder) method\nis that you can put two different labels between them archive policies are different.\n\nIf **shouldArchive** is in the each label, all mails associated to the label are archived.\nBut this method can remain what you want easily.\n\nIn addition, only the order of the filters can be free other than the last label,\nso that it makes easy to modify with the web interface.\nAlthough you still need to \"modify\"\n**hasTheWord: \"-label:99_DummyInbox\"** filter after any other filter changes...\n(such adding one space in **Has the words** and save, and remove the space and save again...)\n\n## References\n\n- [gmail_filter_manager: GmailのフィルタをYAMLで簡単に管理する](https://rcmdnk.com/blog/2018/07/07/computer-gmail-python/)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frcmdnk%2Fgmail_filter_manager","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frcmdnk%2Fgmail_filter_manager","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frcmdnk%2Fgmail_filter_manager/lists"}