Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
offlineimap + notmuch + mutt + gpg + mstmp
xdg-open "$1" &
sleep 1
encrypt_to me@mailaccount
text/html; w3m -I %{charset} -T text/html; copiousoutput;
text/calendar; gcalcli import -d %s; copiousoutput; print=gcalcli --nocolor --reminder=10 --detail_url=short --calendar='me@mailaccount' import %s
application/ics; gcalcli import -d %s; copiousoutput; print=gcalcli --nocolor --reminder=10 --detail_url=short --calendar='me@mailaccount' import %s
image/*; imv %s
application/pgp-keys; pgp -f < %s ; copiousoutput
application/*; %s
# color setup
# ======================================================================
# INDEX OBJECT PATTERN? pattern description
# index pattern default highlighting of the entire index line
# index_date the date field
# index_flags pattern %S %Z the message flags
# index_number %C the message number
# index_collapsed %M the number of messages in a collapsed thread
# index_author pattern %AaFLn the author name
# index_subject pattern %s the subject line
# index_size %c %l the message size
# index_label %y %Y the message label
# index_tags %g the transformed message tags
# index_tag pattern/tag %G an individual message tag
# ======================================================================
color normal default default
color index_number brightblack default
color index_date magenta default
color index_flags yellow default .
color index_collapsed cyan default
color index green default ~N
color index red default ~F
color index cyan default ~T
color index blue default ~D
color index_label brightred default
color index_tags red default
color index_tag brightmagenta default "encrypted"
color index_tag yellow default "attachment"
color body brightwhite default ([a-zA-Z\+]+)://[\-\.,/%~_:?&=\#a-zA-Z0-9]+
color body green default [\-\.+_a-zA-Z0-9]+@[\-\.a-zA-Z0-9]+
color attachment yellow default
color signature green default
color search brightred black
color indicator cyan brightblack
color error brightred default
color status brightcyan brightblack
color tree brightcyan default
color tilde cyan default
color progress white red
color hdrdefault color81 default
color quoted color60 default
color quoted1 yellow default
color body green default "^gpg: Good signature from"
color body brightred default "^gpg: Bad signature from"
color body brightred default "^gpg: BAD signature from"
color body brightred default "^gpg: Note: This key has expired!"
color body brightyellow default "^gpg: WARNING: This key is not certified with a trusted signature!"
color body brightyellow default "^gpg: There is no indication that the signature belongs to the owner."
color body brightyellow default "^gpg: can't handle these multiple signatures"
color body brightyellow default "^gpg: signature verification suppressed"
color body brightyellow default "^gpg: invalid node with packet of type"
import gnomekeyring as gkey
keyring = gkey.get_default_keyring_sync()
attrs = {"repo": "MailAccount"}
items = gkey.find_items_sync(gkey.ITEM_NETWORK_PASSWORD, attrs)
print items[0].secret
# Accounts will inherit settings from this section
auth on
tls on
tls_trust_file /etc/ssl/certs/ca-certificates.crt
account MailAccount
host mail.account
port 465
from me@mailaccount
user me@mailaccount
passwordeval python2 ~/
tls_starttls off
# Set a default account
account default : MailAccount
offlineimap 1>~/.offlineimap/log 2>~/.offlineimap/error_log &
kill $PID
set realname = "My Name"
set from = "me@mailaccount"
set use_from = yes
set sendmail = "/usr/bin/msmtp"
set editor = vim
set charset="utf-8"
set alias_file = ~/.mutt/aliases.muttrc
source ~/.mutt/aliases.muttrc
source /usr/share/doc/mutt/samples/vim-keybindings.rc
source ~/.mutt/molokai.muttrc
set mbox_type = Maildir
set folder = ~/.maildirs/MailAccount/INBOX
set header_cache = ~/.cache/mutt
set spoolfile = +/
set record = +/
set postponed = +/../INBOX.Drafts
set sort = 'threads'
set sort_aux = 'last-date-received'
#set date_format = "%d %b %Y"
set index_format = " %Z %<[y?%<[m?%<[d?%[ %H:%M]&%[ %a %d]>&%[ %b %d]>&%[%d/%m/%Y]> %-30.30F %<M?(%2M)& > %?GE?%GE& ? %?GA?%GA& ? %g %s"
unset help
ignore *
unignore from date subject to cc bcc
folder-hook . "exec collapse-all"
set markers = no
set smart_wrap
set pager_context = 5
set pager_index_lines = 10
set fast_reply = yes
set include = yes
set timeout = 5
set edit_headers = yes
set crypt_use_gpgme = yes
#set pgp_use_gpg_agent = yes
#set pgp_sign_as = mypgpgkeyid
#set smime_default_key = mypgpkeyid
#set smime_encrypt_self = yes
set crypt_verify_sig = yes
set crypt_autosign = yes
set crypt_opportunistic_encrypt = yes
set mailcap_path=~/.mutt/mailcap
alternative_order text/plain text/html
auto_view text/html
auto_view text/calendar
auto_view application/ics
# Edit X-Labels
#bind index,pager yy edit-label
# Notmuch config
set nm_default_uri = "notmuch:///home/me/.maildirs/MailAccount"
set virtual_spoolfile=yes
set nm_hidden_tags = "inbox,unread,draft,flagged,passed,replied,signed,encrypted,attachment"
virtual-mailboxes "inbox" "notmuch://?query=tag:inbox and NOT tag:archive"
macro index \\\\ "<vfolder-from-query>"
macro index,pager A "<modify-labels>+archive -unread -inbox\\n"
bind index,pager + entire-thread
bind index,pager yy modify-labels
bind index,pager X change-vfolder
tag-transforms "attachment" "@" \
"encrypted" ""
tag-formats "attachment" "GA" \
"encrypted" "GE"
macro index,pager ut <tag-thread><limit>~T<enter><tag-thread> "show only current thread"
macro index,pager ua <limit>all<enter> "show everything"
macro attach s <save-entry><kill-line>/home/guiniol/downloads
# .notmuch-config - Configuration file for the notmuch mail system
# For more information about notmuch, see
# Database configuration
# The only value supported here is 'path' which should be the top-level
# directory where your mail currently exists and to where mail will be
# delivered in the future. Files should be individual email messages.
# Notmuch will store its database within a sub-directory of the path
# configured here named ".notmuch".
# User configuration
# Here is where you can let notmuch know how you would like to be
# addressed. Valid settings are
# name Your full name.
# primary_email Your primary email address.
# other_email A list (separated by ';') of other email addresses
# at which you receive email.
# Notmuch will use the various email addresses configured here when
# formatting replies. It will avoid including your own addresses in the
# recipient list of replies, and will set the From address based on the
# address to which the original email was addressed.
name=My Name
# Configuration for "notmuch new"
# The following options are supported here:
# tags A list (separated by ';') of the tags that will be
# added to all messages incorporated by "notmuch new".
# ignore A list (separated by ';') of file and directory names
# that will not be searched for messages by "notmuch new".
# NOTE: *Every* file/directory that goes by one of those
# names will be ignored, independent of its depth/location
# in the mail store.
# Search configuration
# The following option is supported here:
# exclude_tags
# A ;-separated list of tags that will be excluded from
# search results by default. Using an excluded tag in a
# query will override that exclusion.
# Maildir compatibility configuration
# The following option is supported here:
# synchronize_flags Valid values are true and false.
# If true, then the following maildir flags (in message filenames)
# will be synchronized with the corresponding notmuch tags:
# Flag Tag
# ---- -------
# D draft
# F flagged
# P passed
# R replied
# S unread (added when 'S' flag is not present)
# The "notmuch new" command will notice flag changes in filenames
# and update tags, while the "notmuch tag" and "notmuch restore"
# commands will notice tag changes and update flags in filenames
# Cryptography related configuration
# The following option is supported here:
# gpg_path
# binary name or full path to invoke gpg.
notmuch new --try-decrypt
notmuch tag +list tag:tofilter and subject:\([LIST]\)
notmuch tag +friend tag:tofilter and from:friend
notmuch tag -tofilter tag:tofilter and from:me@mailaccount
COUNT=$(notmuch count tag:tofilter)
notmuch tag -tofilter tag:tofilter
if [ ${COUNT} != 0 ]; then
notify-send -h string:bgcolor:#3579a8 -h string:fgcolor:#d0d0d0 "MAIL MOTHERFUCKER !!" "${COUNT} new messages"
mpv ~/.mutt/mail_motherfucker.m4a >/dev/null 2>&1
import gnomekeyring as gkey
def set_credentials(repo, user, pw):
KEYRING_NAME = "offlineimap"
attrs = { "repo": repo, "user": user }
keyring = gkey.get_default_keyring_sync()
gkey.item_create_sync(keyring, gkey.ITEM_NETWORK_PASSWORD, KEYRING_NAME, attrs, pw, True)
def get_credentials(repo):
keyring = gkey.get_default_keyring_sync()
attrs = {"repo": repo}
items = gkey.find_items_sync(gkey.ITEM_NETWORK_PASSWORD, attrs)
return (items[0].attributes["user"], items[0].secret)
def get_username(repo):
return get_credentials(repo)[0]
def get_password(repo):
return get_credentials(repo)[1]
if __name__ == "__main__":
import sys
import os
import getpass
if len(sys.argv) != 3:
print "Usage: %s <repository> <username>" \
% (os.path.basename(sys.argv[0]))
repo, username = sys.argv[1:]
password = getpass.getpass("Enter password for user '%s': " % username)
password_confirmation = getpass.getpass("Confirm password: ")
if password != password_confirmation:
print "Error: password confirmation does not match"
set_credentials(repo, username, password)
metadata = ~/.offlineimap
accounts = MailAccount
# maxsyncaccounts = 1
ui = basic
# ignore-readonly = no
pythonfile = ~/
socktimeout = 60
# fsync = true
[Account MailAcccount]
localrepository = LocalMailAccount
remoterepository = RemoteMailAccount
autorefresh = 5
quick = 10
# presynchook = imapfilter
postsynchook = ~/
status_backend = sqlite
# maxsize = 2000000
# maxage =
# maildir-windows-compatible = no
# synclabels = no
# labelsheader = X-Keywords
# ignorelabels = \Inbox, \Starred, \Sent, \Draft, \Spam, \Trash, \Important
# filterheaders = X-Some-Weird-Header
[Repository LocalMailAccount]
type = Maildir
localfolders = ~/.maildirs/MailAccount
# sep = .
# restoreatime = no
[Repository RemoteMailAccount]
type = IMAP
remotehost = mail.account
ssl = yes
remoteusereval = get_username("MailAccount")
remotepasseval = get_password("MailAccount")
cert_fingerprint = mailaccountfingerprint
# ssl_version = ssl23
# remoteport = 993
# preauthtunnel = ssh -q imaphost '/usr/bin/imapd ./Maildir'
# transporttunnel = openssl s_client -host myimap -port 993 -quiet
# reference = Mail
# idlefolders = ['INBOX', 'INBOX.Alerts']
# usecompression = yes
# maxconnections = 2
# holdconnectionopen = no
# keepalive = 60
# expunge = no
# subscribedonly = no
# nametrans = lambda foldername: re.sub('^INBOX\.', '', foldername)
# dynamic_folderfilter = False
# folderfilter = lambda foldername: foldername in ['INBOX', 'Sent']
# folderincludes = ['debian.user', 'debian.personal']
# createfolders = True
# foldersort = lambda x, y: -cmp(x, y)
# readonly = False
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment