Add email configuration

This commit is contained in:
Ian Adam Naval 2015-04-21 09:49:36 -04:00
parent 68c5567d56
commit 77076a536e
14 changed files with 382 additions and 0 deletions

4
bin/README Normal file
View File

@ -0,0 +1,4 @@
Just a collection of useful programs. I usually just stick all of these in
/usr/local/bin because I am too lazy to have a ~/.bin directory or something
similar.

56
bin/exchangebook Executable file
View File

@ -0,0 +1,56 @@
#!/bin/sh
# Crappy shell script to parse WPI's address book. Designed for mutt.
# Uses LDAP over TLS to query information.
#
# To use in mutt, add this to your .muttrc
# set query_command="/path/to/this/script '%s'"
#
# To combine with goobook, you can just do this:
# set query_command="goobook query '%s'; /path/to/this/script '%s'"
# pass all arguments to LDAP search
query=$@
# authentication
username=ianaval
password=$(pass WPI_UNIX)
# sketchy, but we don't require verification of TLS certs
# at least we're not transmitting plaintext passwords
export LDAPTLS_REQCERT=never
# Use WPI's PAM binddn to get the user's binddn
binddn=$(ldapsearch -ZZ -LLL -x -b dc=wpi,dc=edu -H ldap://ldapv2back.wpi.edu/ -D cn=pam,ou=access,dc=wpi,dc=edu -w $(pass ldapv2back) "(|(uid=$username))" dn | awk '{print $2}' 2>/dev/null)
# Makes names look like "Naval, Ian A."
parse_name() {
case $# in
2) echo "$2, $1" ;;
3) echo "$3, $1 ${2:0:1}." ;;
*) echo "$@" ;;
esac
}
# loop line by line
OIFS="${IFS}"
NIFS=$'\n'
IFS="${NIFS}"
for line in $(ldapsearch -ZZ -LLL -x -H ldap://ldapv2back.wpi.edu/ -D $binddn -w $password -b "dc=wpi,dc=edu" "(|(uid=$query)(cn=*$query*)(displayName=*$query*))" displayName mail 2>/dev/null); do
IFS="${OIFS}"
# parse displayName (might not be in the right order)
if [[ $line =~ displayName* ]]; then
displayName=$(parse_name $(echo "$line" | sed -e 's/displayName: //'))
fi
# parse email
if [[ $line =~ mail* ]]; then
mail=$(echo "$line" | sed -e 's/mail: //')
fi
# print address book record with the group being 'none'
if [[ -n $displayName ]] && [[ -n $mail ]]; then
printf "$mail\t$displayName\tnone\n"
displayName=""
mail=""
fi
IFS="${NIFS}"
done
IFS="${OIFS}"

17
mutt/gookbookrc.dotfile Normal file
View File

@ -0,0 +1,17 @@
# "#" or ";" at the start of a line makes it a comment.
[DEFAULT]
# If not given here, email and password is taken from .netrc using
# machine google.com
email: ianonavy@gmail.com
passwordeval: pass mbsync
# The following are optional, defaults are shown
cache_filename: ~/.goobook_cache
cache_expiry_hours: 24
;filter_groupless_contacts: yes
# New contacts will be added to this group in addition to "My Contacts"
# Note that the group has to already exist on google or an error will occur.
# One use for this is to add new contacts to an "Unsorted" group, which can
# be sorted easier than all of "My Contacts".
# searching for groupless users is a bit painful.
default_group:Unsorted

85
mutt/mbsyncrc.dotfile Normal file
View File

@ -0,0 +1,85 @@
# ------------------------------------------------------------------------------
# gmail - ianonavy@gmail.com
# ------------------------------------------------------------------------------
IMAPAccount gmail
Host imap.gmail.com
User ianonavy@gmail.com
PassCmd "pass mbsync"
SSLType IMAPS
SSLVersions TLSv1.2
CertificateFile /etc/ssl/certs/ca-certificates.crt
IMAPStore gmail-remote
Account gmail
MaildirStore gmail-local
# The trailing "/" is important
Path ~/.mail/gmail/
Inbox ~/.mail/gmail/Inbox
Channel sync-gmail-default
Master :gmail-remote:
Slave :gmail-local:
# Select some mailboxes to sync
Patterns "INBOX" "Banking"
Create Both
SyncState *
Channel sync-gmail-archived
Master :gmail-remote:"[Gmail]/All Mail"
Slave :gmail-local:Archived
Create Slave
SyncState *
Channel sync-gmail-sent
Master :gmail-remote:"[Gmail]/Sent Mail"
Slave :gmail-local:Sent
Create Slave
SyncState *
Channel sync-gmail-spam
Master :gmail-remote:"[Gmail]/Spam"
Slave :gmail-local:Spam
Create Slave
SyncState *
Channel sync-gmail-trash
Master :gmail-remote:"[Gmail]/Trash"
Slave :gmail-local:Trash
Create Slave
SyncState *
# Get all the channels together into a group.
Group gmail
Channel sync-gmail-default
Channel sync-gmail-archived
Channel sync-gmail-sent
Channel sync-gmail-spam
Channel sync-gmail-trash
# ------------------------------------------------------------------------------
# school - ianaval@wpi.edu
# ------------------------------------------------------------------------------
IMAPAccount school
Host exchange.wpi.edu
User ianaval@wpi.edu
PassCmd "pass WPI_Email"
SSLType IMAPS
SSLVersions TLSv1 TLSv1.1 TLSv1.2
CertificateFile /etc/ssl/certs/ca-certificates.crt
IMAPStore school-remote
Account school
MaildirStore school-local
# The trailing "/" is important
Path ~/.mail/school/
Inbox ~/.mail/school/Inbox
Channel school
Master :school-remote:
Slave :school-local:
# Select some mailboxes to sync
Patterns *
Create Both
SyncState *

1
mutt/mutt.dotfile/.gitignore vendored Normal file
View File

@ -0,0 +1 @@
shadow.gpg

0
mutt/mutt.dotfile/alias Normal file
View File

View File

14
mutt/mutt.dotfile/crypto Normal file
View File

@ -0,0 +1,14 @@
# -*-muttrc-*-
set pgp_decode_command="gpg %?p?--passphrase-fd 0? --no-verbose --batch --output - %f"
set pgp_verify_command="gpg --no-verbose --batch --output - --verify %s %f"
set pgp_decrypt_command="gpg --passphrase-fd 0 --no-verbose --batch --output - %f"
set pgp_sign_command="gpg --no-verbose --batch --output - --passphrase-fd 0 --armor --detach-sign --textmode %?a?-u %a? %f"
set pgp_clearsign_command="gpg --no-verbose --batch --output - --passphrase-fd 0 --armor --textmode --clearsign %?a?-u %a? %f"
set pgp_encrypt_only_command="pgpewrap gpg --batch --quiet --no-verbose --output - --encrypt --textmode --armor --always-trust --encrypt-to 0x8C8474B3 -- -r %r -- %f"
set pgp_encrypt_sign_command="pgpewrap gpg --passphrase-fd 0 --batch --quiet --no-verbose --textmode --output - --encrypt --sign %?a?-u %a? --armor --always-trust --encrypt-to 0x8C8474B3 -- -r %r -- %f"
set pgp_import_command="gpg --no-verbose --import -v %f"
set pgp_export_command="gpg --no-verbose --export --armor %r"
set pgp_verify_key_command="gpg --no-verbose --batch --fingerprint --check-sigs %r"
set pgp_list_pubring_command="gpg --no-verbose --batch --with-colons --list-keys %r"
set pgp_list_secring_command="gpg --no-verbose --batch --with-colons --list-secret-keys %r"

21
mutt/mutt.dotfile/gmail Normal file
View File

@ -0,0 +1,21 @@
# -*-muttrc-*-
set imap_user=ianonavy@gmail.com
set imap_pass=$my_pw_gmail
set folder=/home/ian/.mail/gmail/
#set mbox=+Archived
set spoolfile=+Inbox
unmailboxes *
mailboxes \
+Inbox \
+Archived \
+Banking \
+Sent \
+Trash
set realname = 'Ian Adam Naval'
set from = ianonavy@gmail.com
set use_from = yes
set smtp_url=smtps://ianonavy@gmail.com:$my_pw_gmail@smtp.gmail.com
set ssl_force_tls = yes

View File

@ -0,0 +1,17 @@
# -*-muttrc-*-
set imap_user=ian@ianonavy.com
set imap_pass="$my_pw_ianonavy"
set folder=imaps://ian@ianonavy.com@imap.gmail.com/
set mbox="imaps://imap.gmail.com/[Gmail]/All Mail"
set spoolfile=+INBOX
mailboxes =INBOX
mailboxes imaps://ian@ianonavy.com@imap.gmail.com/INBOX
set realname = 'Ian Adam Naval'
set from = ian@ianonavy.com
set use_from = yes
set smtp_url=smtps://ian@ianonavy.com:$my_pw_ianonavy@smtp.gmail.com
set ssl_force_tls = yes
account-hook $folder "set imap_user=ian@ianonavy.com imap_pass=$my_pw_ianonavy"

View File

@ -0,0 +1,3 @@
text/html; elinks %s; nametemplate=%s.html
text/html; elinks -dump -default-mime-type text/html %s; needsterminal; copiousoutput;
image/*; feh %s;

24
mutt/mutt.dotfile/school Normal file
View File

@ -0,0 +1,24 @@
#-*-muttrc-*-
set imap_user=ianaval@wpi.edu
set imap_pass=$my_pw_school
set folder=/home/ian/.mail/school/
set postponed=+Drafts
set record="+Sent Items"
set mbox=+Archived
set spoolfile=+Inbox
unmailboxes *
mailboxes \
+Inbox \
+Archived \
+Drafts \
+"Sent Items" \
+"Junk E-mail" \
+Trash
set realname = 'Naval, Ian A'
set from = ianaval@wpi.edu
set use_from = yes
set smtp_url=smtps://ianaval:$my_pw_school@submission.wpi.edu
set ssl_force_tls = yes

24
mutt/mutt.dotfile/work Normal file
View File

@ -0,0 +1,24 @@
# -*-muttrc-*-
set imap_user=ian@adhamonics.com
set imap_pass=$my_pw_work
set folder=imaps://ian@adharmonics.com@imap.gmail.com/
set mbox="imaps://imap.gmail.com/[Gmail]/All Mail"
set spoolfile=+INBOX
unmailboxes *
mailboxes \
+INBOX \
+"[Gmail]/All Mail" \
+"[Gmail]/Drafts" \
+"[Gmail]/Sent Mail" \
+"[Gmail]/Spam" \
+"[Gmail]/Trash"
set realname = 'Ian Adam Naval'
set from = ian@adharmonics.com
set use_from = yes
set smtp_url=smtps://ian@adharmonics.com:$my_pw_work@smtp.gmail.com
set ssl_force_tls = yes
account-hook $folder "set imap_user=ian@adharmonics.com imap_pass=$my_pw_work"

116
mutt/muttrc.dotfile Normal file
View File

@ -0,0 +1,116 @@
# -*-muttrc-*-
source "gpg2 -dq $HOME/.mutt/shadow.gpg |""
source ~/.mutt/crypto
# PGP ------------------------------------------------
set pgp_use_gpg_agent = yes
set pgp_autosign = yes
set pgp_auto_decode = yes
# Index Key Bindings ---------------------------------
bind index gg first-entry
bind index G last-entry
bind index R group-reply
bind index <tab> sync-mailbox
bind index <space> collapse-thread
# Ctrl-R to mark all as read
macro index \Cr "T~U<enter><tag-prefix><clear-flag>N<untag-pattern>.<enter>" "mark all messages as read"
# Ctrl-A to archive all
macro index \Ca "T.*<enter><tag-prefix><save-message>=Archived<enter>" "archive all message"
# Sync email
macro index ss "<shell-escape>mbsync -a<enter>"
# Saner copy/move dialogs
macro index C "<copy-message>?<toggle-mailboxes>" "copy a message to a mailbox"
macro index M "<save-message>?<toggle-mailboxes>" "move a message to a mailbox"
macro index,pager A "<save-message>=Archived<enter>" "Archive Message"
# Goobook
macro index,pager a "<pipe-message>goobook add<return>" "add sender to google contacts"
bind editor <Tab> complete-query
# Sidebar Navigation ---------------------------------
bind index,pager <down> sidebar-next
bind index,pager <up> sidebar-prev
bind index,pager <right> sidebar-open
macro index b '<enter-command>toggle sidebar_visible<enter><refresh>'
macro pager b '<enter-command>toggle sidebar_visible<enter><redraw-screen>'
bind index B bounce-message
# Basic Options --------------------------------------
set sort = threads # prettier inbox
set wait_key = no # shut up, mutt
set mbox_type = Maildir # mailbox type
set timeout = 3 # idle time before scanning
set mail_check = 0 # minimum time between scans
unset move # gmail does that
set delete # don't ask, just do
unset confirmappend # don't ask, just do!
set quit # don't ask, just do!!
unset mark_old # read/new is good enough for me
set beep_new # bell on new mails
set pipe_decode # strip headers and eval mimes when piping
set thorough_search # strip headers and eval mimes before searching
unset record # gmail saves a copy of the sent message
set query_command = "goobook query '%s'; exchangebook '%s'"
alternative_order text/html text/enriched text/plain
auto_view text/html
# Paths ----------------------------------------------
set folder = ~/.mail # mailbox location
set alias_file = ~/.mutt/alias # where to store aliases
set header_cache = ~/.mutt/cache/headers # where to store headers
set message_cachedir = ~/.mutt/cache/bodies # where to store bodies
set certificate_file = ~/.mutt/certificates # where to store certs
set mailcap_path = ~/.mutt/mailcap # entries for filetypes
set tmpdir = ~/.mutt/temp # where to keep temp files
# Sidebar Patch --------------------------------------
set sidebar_delim = ' │'
set sidebar_visible = yes
set sidebar_width = 32
color sidebar_new color221 color233
# Status Bar -----------------------------------------
set status_chars = " *%A"
set status_format = "───[ Folder: %f ]───[%r%m messages%?n? (%n new)?%?d? (%d to delete)?%?t? (%t tagged)? ]───%>─%?p?( %p postponed )?───"
# Accounts -------------------------------------------
source "~/.mutt/ianonavy.com"
folder-hook $folder 'source ~/.mutt/ianonavy.com'
macro index,pager oi '<sync-mailbox><enter-command>source ~/.mutt/ianonavy.com<enter><change-folder>!<enter>'
source "~/.mutt/work"
folder-hook $folder 'source ~/.mutt/work'
macro index,pager ow '<sync-mailbox><enter-command>source ~/.mutt/work<enter><change-folder>!<enter>'
source "~/.mutt/gmail"
folder-hook $folder 'source ~/.mutt/gmail'
macro index,pager og '<sync-mailbox><enter-command>source ~/.mutt/gmail<enter><change-folder>!<enter>'
source "~/.mutt/school"
folder-hook $folder 'source ~/.mutt/school'
macro index,pager os '<sync-mailbox><enter-command>source ~/.mutt/school<enter><change-folder>!<enter>'
# Palette for use with the Linux console. Black background.
color hdrdefault blue black
color quoted blue black
color signature blue black
color attachment red black
color message brightred black
color error brightred black
color indicator black green
color status brightgreen black
color tree white black
color normal white black
color markers red black
color search white black
color tilde brightmagenta black
color index blue black ~F
color index red black "~N|~O"
color body brightwhite black '\*+[^*]+\*+'
color body brightwhite black '_+[^_]+_+'