diff options
author | Jason Gunthorpe <jgg@mellanox.com> | 2020-02-05 13:50:31 -0400 |
---|---|---|
committer | Jason Gunthorpe <jgg@mellanox.com> | 2020-02-07 11:25:26 -0400 |
commit | f44a42f276e01514a1e4bf3028639aaea58138c6 (patch) | |
tree | 5bbc0cb32a31f9b285d8158b7e8053f6a4d22c42 /README.md | |
parent | f578f75464791e7bfbf6b2544fd8651fe8b6f974 (diff) | |
download | cloud_mdir_sync-f44a42f276e01514a1e4bf3028639aaea58138c6.tar.gz cloud_mdir_sync-f44a42f276e01514a1e4bf3028639aaea58138c6.tar.bz2 cloud_mdir_sync-f44a42f276e01514a1e4bf3028639aaea58138c6.zip |
Allow access to the message headers during mail directing
Access to the headers like List-ID allows some client side filtering of
incoming messages.
Signed-off-by: Jason Gunthorpe <jgg@mellanox.com>
Diffstat (limited to 'README.md')
-rw-r--r-- | README.md | 42 |
1 files changed, 42 insertions, 0 deletions
@@ -93,6 +93,48 @@ virtual environment. The included 'cloud-mdir-sync' script will automatically create the required virtual environment with the needed packages downloaded with pip and then run the program from within it. +## Client side filtering + +By default CMS supports only a single local MailDir. All cloud mailbox are +synchronized into it. + +With client side filtering multiple local MailDirs can be used and messages +can be routed into them. + +Here is an example of how to download from two cloud accounts into two +MailDirs: + +```python +gmail_md = MailDir("~/mail/gmail") +gmail_cloud = GMail("INBOX", GMail_Account(user="user@domain.com")) + +o365_md = MailDir("~/mail/o365") +o365_cloud = Office365("inbox", Office365_Account(user="user@domain.com")) + +def direct_message(msg): + if msg.mailbox is gmail_cloud: + return gmail_md + else: + return o365_md +cfg.direct_message = direct_message +``` + +Filtering can also inspect message headers, this example will filter messages by +List-ID: + +```python +def direct_message(msg): + list_id = msg.get_header("List-ID") + if list_id == "<foo-list>" + return foo_md + if list_id == "<bar-list>" + return bar_md + return default_md +``` + +All messages must be routed somewhere, they cannot be deleted through +directing. + # OAUTH2 Authentication Most cloud providers are now using OAUTH2, and often also provide options to |