Compare commits
1 Commits
Author | SHA1 | Date |
---|---|---|
Gwen | 9334e39d30 |
|
@ -0,0 +1,39 @@
|
||||||
|
# GPG password extraction adapted from stackexchange
|
||||||
|
# https://unix.stackexchange.com/questions/44214
|
||||||
|
|
||||||
|
import os, subprocess, re
|
||||||
|
|
||||||
|
def decrypt(path):
|
||||||
|
args = ["gpg", "--use-agent", "--quiet", "--batch", "-d", path]
|
||||||
|
try:
|
||||||
|
return subprocess.check_output(args).strip()
|
||||||
|
except BaseException as e:
|
||||||
|
print("[ERROR] %s" % e)
|
||||||
|
return ""
|
||||||
|
|
||||||
|
# Extract account information stored in key/value paris
|
||||||
|
def get_account(acct, key):
|
||||||
|
acct = os.path.basename(acct)
|
||||||
|
path = os.path.expanduser("~/.passwd/%s.gpg" % str(acct))
|
||||||
|
o = decrypt(path).splitlines()
|
||||||
|
values = {k.strip():v.strip() for k, v in (l.split('=') for l in o)}
|
||||||
|
return values[key]
|
||||||
|
|
||||||
|
default_folders = ['INBOX', 'Archive', 'Sent', 'Trash']
|
||||||
|
|
||||||
|
def folder_filter(name):
|
||||||
|
# Mail provider has a folder with my mail folders called `Folders`.
|
||||||
|
# Anything inside `Folders` should be synced: match the first
|
||||||
|
# part of the path to allow them, otherwise only sync the inbox
|
||||||
|
# and other default folders.
|
||||||
|
return name[:7] == "Folders" or name in default_folders
|
||||||
|
|
||||||
|
def folder_rename(name):
|
||||||
|
# Nested folders have `Folders.` as a prefix to indicate nesting.
|
||||||
|
# Remove the prefix so names match, unless doing so would clash
|
||||||
|
# with the default folders
|
||||||
|
stripped = re.sub('^Folders.', '', name);
|
||||||
|
if stripped not in default_folders:
|
||||||
|
return stripped
|
||||||
|
else:
|
||||||
|
return name
|
|
@ -0,0 +1,37 @@
|
||||||
|
[general]
|
||||||
|
accounts = main
|
||||||
|
pythonfile = ~/.offlineimap.py
|
||||||
|
|
||||||
|
[Account main]
|
||||||
|
localrepository = main-local
|
||||||
|
remoterepository = main-remote
|
||||||
|
# full refresh, in min
|
||||||
|
autorefresh = 0.2
|
||||||
|
# quick refreshs between each full refresh
|
||||||
|
quick = 10
|
||||||
|
# update notmuch index after sync
|
||||||
|
postsynchook = notmuch new
|
||||||
|
|
||||||
|
[Repository main-local]
|
||||||
|
type = Maildir
|
||||||
|
localfolders = ~/.mail
|
||||||
|
# delete remote mails that were deleted locally
|
||||||
|
sync_deletes = yes
|
||||||
|
|
||||||
|
[Repository main-remote]
|
||||||
|
type = IMAP
|
||||||
|
remoteport = 1143
|
||||||
|
remotehost = 127.0.0.1
|
||||||
|
remoteusereval = get_account('main-email', 'user')
|
||||||
|
remotepasseval = get_account('main-email', 'password')
|
||||||
|
keepalive = 60
|
||||||
|
holdconnectionopen = yes
|
||||||
|
# delete local mails that were deleted on the remote server
|
||||||
|
expunge = yes
|
||||||
|
# sync only these folders
|
||||||
|
folderfilter = folder_filter
|
||||||
|
nametrans = folder_rename
|
||||||
|
# SSL
|
||||||
|
ssl = no
|
||||||
|
starttls = yes
|
||||||
|
sslcacertfile = ~/.mailcert.pem
|
8
setup.sh
8
setup.sh
|
@ -40,9 +40,9 @@ ln -sbv "$DIR/git/.gitattributes_global" ~
|
||||||
|
|
||||||
# e-mail
|
# e-mail
|
||||||
echo -e "\n\t${BOLD}email...${NC}\n"
|
echo -e "\n\t${BOLD}email...${NC}\n"
|
||||||
ln -sbv "$DIR/mail/.mbsyncrc" ~
|
ln -sbv "$DIR/mail/.offlineimaprc" ~
|
||||||
ln -sbv "$DIR/mail/.msmtprc" ~
|
ln -sbv "$DIR/mail/.offlineimap.py" ~
|
||||||
ln -sbv "$DIR/mail/.notmuch-config" ~
|
ln -sbv "$DIR/mail/.notmuch-config" ~
|
||||||
ln -sbv "$DIR/mail/.afew-config" ~/.config/afew/config
|
ln -sbv "$DIR/mail/.afew-config" ~/.config/afew/config
|
||||||
ln -sbv "$DIR/service/checkmail.service" ~/.config/systemd/user/
|
ln -sbv "$DIR/mail/checkmail.service" ~/.config/systemd/user/
|
||||||
ln -sbv "$DIR/service/checkmail.timer" ~/.config/systemd/user/
|
ln -sbv "$DIR/mail/checkmail.timer" ~/.config/systemd/user/
|
||||||
|
|
Loading…
Reference in New Issue