diff options
| author | alex <alex@pdp7.net> | 2023-10-19 22:09:54 +0200 |
|---|---|---|
| committer | alex <alex@pdp7.net> | 2023-10-19 22:09:54 +0200 |
| commit | c756cf590ab20ae90979b0a71b43f600dfbd1224 (patch) | |
| tree | eedcdda0652f5d5ba5eff50f19ac30770d0f26e2 /scripts/p7s/mail | |
| parent | d7437aae5d15f107fdc52dc33f23908449a602c5 (diff) | |
Refactor mbsync stuff
Diffstat (limited to 'scripts/p7s/mail')
| -rw-r--r-- | scripts/p7s/mail/__init__.py | 14 | ||||
| -rw-r--r-- | scripts/p7s/mail/mbsync.py | 54 |
2 files changed, 68 insertions, 0 deletions
diff --git a/scripts/p7s/mail/__init__.py b/scripts/p7s/mail/__init__.py new file mode 100644 index 00000000..f5db2d86 --- /dev/null +++ b/scripts/p7s/mail/__init__.py @@ -0,0 +1,14 @@ +import pathlib + +from p7s import bitwarden +from p7s.mail import mbsync + + +def generate_config(): + gmail = bitwarden.get_item("https://bitwarden.pdp7.net", "alex@corcoles.net", "cad137b0-cfd5-4d5c-b167-98a9e792f4cc")["login"] + yahoo = bitwarden.get_item("https://bitwarden.pdp7.net", "alex@corcoles.net", "e24727e7-c0ef-4c97-afd0-8497d547304c")["login"] + (pathlib.Path.home() / (".mbsyncrc")).write_text( + mbsync.mbsync_gmail(gmail["username"], gmail["password"], "~/Mail") + + "\n" + + mbsync.mbsync_yahoo(yahoo["username"], yahoo["password"], "~/Mail") + ) diff --git a/scripts/p7s/mail/mbsync.py b/scripts/p7s/mail/mbsync.py new file mode 100644 index 00000000..0aabeea1 --- /dev/null +++ b/scripts/p7s/mail/mbsync.py @@ -0,0 +1,54 @@ +import textwrap + + +def mbsync_gmail(login, password, store_path): + return textwrap.dedent(f""" + IMAPAccount {login} + Host imap.gmail.com + SSLType IMAPS + User {login} + Pass {password} + + IMAPStore {login}-remote + Account {login} + + MaildirStore {login}-local + SubFolders Verbatim + Path {store_path}/{login}/ + Inbox {store_path}/{login}/Inbox + + Channel {login} + Far :{login}-remote: + Near :{login}-local: + Patterns * + Create Both + Expunge Both + SyncState * + """).lstrip() + + +def mbsync_yahoo(login, password, store_path): + return textwrap.dedent(f""" + IMAPAccount {login} + Host imap.mail.yahoo.com + SSLType IMAPS + User {login} + Pass {password} + PipelineDepth 5 + + IMAPStore {login}-remote + Account {login} + + MaildirStore {login}-local + SubFolders Verbatim + Path {store_path}/{login}/ + Inbox {store_path}/{login}/Inbox + + Channel {login} + Far :{login}-remote: + Near :{login}-local: + Patterns * + Create Both + Expunge Both + SyncState * + """).lstrip() |
