Luke 6 лет назад
Сommit
914a1bf4d8
12 измененных файлов: 427 добавлений и 0 удалений
  1. +38
    -0
      README.md
  2. +88
    -0
      autoconf/domains.csv
  3. +26
    -0
      autoconf/mutt_profile
  4. +6
    -0
      autoconf/offlineimap_header
  5. +18
    -0
      autoconf/offlineimap_profile
  6. +4
    -0
      credentials/getmuttpass
  7. +11
    -0
      credentials/imappwd.py
  8. +17
    -0
      manual.sh
  9. +80
    -0
      mutt_install.sh
  10. +111
    -0
      offlineimap
  11. +20
    -0
      removeaccount.sh
  12. +8
    -0
      stat.sh

+ 38
- 0
README.md Просмотреть файл

@@ -0,0 +1,38 @@
# mutt Offline email setup

Mutt is one of the most rewarding programs one can use, but can be a pain in the ass to configure. Since my job is making power-user tools available for the masses I want to create a tool that automates most of mutt configuration so that users can simply give their email address and get a /comfy/ setup. At that, I don't just want a mutt wizard, but an offlineIMAP wizard, so users can easily access their mail offline as well, and a wizard that makes it easy to store passwords securely using gpg.

## Progress

The main scripts `mutt_install.sh` can create or add an account from a domain in `domain.csv` to `~/.offlineimaprc` without a problem.

## YOU CAN HELP

If you use mutt with a particular host or domain, put your server information in `domains.csv`! This will make everyone else who uses your email provider's life much easier!

Or you can help monetarily via [Patreon](https://patreon.com/lukesmith) or [Paypal](https://paypal.me/LukeMSmith)!

## Todo

* Expand the list of server information in `domains.csv`, including adding spoolfiles/records/postponed folders for each account.
* Write scripts that do the following:
* Stat `~/.offlineimaprc` and the the mutt configs to see what accounts are currently available. (**Done**, currently in `stat.sh`; needs integration.)
* Delete a profile from above if requested. (**Done**, currently in `removeaccount.sh`; needs integration.)
* Add a profile above if requested, including:
* An automatic search of `domains.csv` for server information. (**Done**)
* An ncurses menu for inputing server settings if not available in `domains.csv`. (Soon, see `manual.sh`)
* Differential actions for Gmail accounts since these are distinct in offlineIMAP. (**Done**)
* Configure notmuch with all accounts.
* A prompt for adding encypted passwords for each account available.
* Or directions for adding plain text passwords if desired.

### Todo: Add settings for email accounts not unified by one domain

--------

zoho,imap.zoho.com,993.00,smtp.zoho.com,465.00
icloud,imap.mail.me.com,993.00,smtp.mail.me.com,587.00
inbox.com,imap.inbox.com,993.00,smtp.inbox.com,465.00
office365,outlook.office365.com,993.00,smtp.office365.com,587.00
hostgator,gator4171.hostgator.com,993.00,gator4171.hostgator.com,587.00
godaddy,imap.secureserver.net,993,smtpout.secureserver.net,465

+ 88
- 0
autoconf/domains.csv Просмотреть файл

@@ -0,0 +1,88 @@
ADDRESS,IMAP,imap port,SMTP,smtp port,spoolfile,postponed,record
yahoo.com,imap.mail.yahoo.com,993.00,smtp.mail.yahoo.com,465/587,,,
mail.com,imap.mail.com,995.00,smtp.mail.com,587.00,INBOX,Drafts,Sent
aol.com,imap.aol.com,993.00,smtp.aol.com,465.00,,,
email.com,imap.mail.com,995.00,smtp.mail.com,587.00,INBOX,Drafts,Sent
usa.com,imap.mail.com,995.00,smtp.mail.com,587.00,INBOX,Drafts,Sent
myself.com,imap.mail.com,995.00,smtp.mail.com,587.00,INBOX,Drafts,Sent
consultant.com,imap.mail.com,995.00,smtp.mail.com,587.00,INBOX,Drafts,Sent
post.com,imap.mail.com,995.00,smtp.mail.com,587.00,INBOX,Drafts,Sent
europe.com,imap.mail.com,995.00,smtp.mail.com,587.00,INBOX,Drafts,Sent
asia.com,imap.mail.com,995.00,smtp.mail.com,587.00,INBOX,Drafts,Sent
iname.com,imap.mail.com,995.00,smtp.mail.com,587.00,INBOX,Drafts,Sent
writeme.com,imap.mail.com,995.00,smtp.mail.com,587.00,INBOX,Drafts,Sent
dr.com,imap.mail.com,995.00,smtp.mail.com,587.00,INBOX,Drafts,Sent
engineer.com,imap.mail.com,995.00,smtp.mail.com,587.00,INBOX,Drafts,Sent
cheerful.com,imap.mail.com,995.00,smtp.mail.com,587.00,INBOX,Drafts,Sent
accountant.com,imap.mail.com,995.00,smtp.mail.com,587.00,INBOX,Drafts,Sent
techie.com,imap.mail.com,995.00,smtp.mail.com,587.00,INBOX,Drafts,Sent
linuxmail.org,imap.mail.com,995.00,smtp.mail.com,587.00,INBOX,Drafts,Sent
uymail.com,imap.mail.com,995.00,smtp.mail.com,587.00,INBOX,Drafts,Sent
contractor.net,imap.mail.com,995.00,smtp.mail.com,587.00,INBOX,Drafts,Sent
accountant.com,imap.mail.com,995.00,smtp.mail.com,587.00,INBOX,Drafts,Sent
activist.com,imap.mail.com,995.00,smtp.mail.com,587.00,INBOX,Drafts,Sent
adexec.com,imap.mail.com,995.00,smtp.mail.com,587.00,INBOX,Drafts,Sent
allergist.com,imap.mail.com,995.00,smtp.mail.com,587.00,INBOX,Drafts,Sent
alumni.com,imap.mail.com,995.00,smtp.mail.com,587.00,INBOX,Drafts,Sent
alumnidirector.com,imap.mail.com,995.00,smtp.mail.com,587.00,INBOX,Drafts,Sent
angelic.com,imap.mail.com,995.00,smtp.mail.com,587.00,INBOX,Drafts,Sent
appraiser.net,imap.mail.com,995.00,smtp.mail.com,587.00,INBOX,Drafts,Sent
archaeologist.com,imap.mail.com,995.00,smtp.mail.com,587.00,INBOX,Drafts,Sent
arcticmail.com,imap.mail.com,995.00,smtp.mail.com,587.00,INBOX,Drafts,Sent
artlover.com,imap.mail.com,995.00,smtp.mail.com,587.00,INBOX,Drafts,Sent
asia.com,imap.mail.com,995.00,smtp.mail.com,587.00,INBOX,Drafts,Sent
auctioneer.net,imap.mail.com,995.00,smtp.mail.com,587.00,INBOX,Drafts,Sent
bartender.net,imap.mail.com,995.00,smtp.mail.com,587.00,INBOX,Drafts,Sent
bikerider.com,imap.mail.com,995.00,smtp.mail.com,587.00,INBOX,Drafts,Sent
birdlover.com,imap.mail.com,995.00,smtp.mail.com,587.00,INBOX,Drafts,Sent
brew-meister.com,imap.mail.com,995.00,smtp.mail.com,587.00,INBOX,Drafts,Sent
cash4u.com,imap.mail.com,995.00,smtp.mail.com,587.00,INBOX,Drafts,Sent
chef.net,imap.mail.com,995.00,smtp.mail.com,587.00,INBOX,Drafts,Sent
chemist.com,imap.mail.com,995.00,smtp.mail.com,587.00,INBOX,Drafts,Sent
clerk.com,imap.mail.com,995.00,smtp.mail.com,587.00,INBOX,Drafts,Sent
clubmember.org,imap.mail.com,995.00,smtp.mail.com,587.00,INBOX,Drafts,Sent
collector.org,imap.mail.com,995.00,smtp.mail.com,587.00,INBOX,Drafts,Sent
columnist.com,imap.mail.com,995.00,smtp.mail.com,587.00,INBOX,Drafts,Sent
comic.com,imap.mail.com,995.00,smtp.mail.com,587.00,INBOX,Drafts,Sent
computer4u.com,imap.mail.com,995.00,smtp.mail.com,587.00,INBOX,Drafts,Sent
consultant.com,imap.mail.com,995.00,smtp.mail.com,587.00,INBOX,Drafts,Sent
contractor.net,imap.mail.com,995.00,smtp.mail.com,587.00,INBOX,Drafts,Sent
coolsite.net,imap.mail.com,995.00,smtp.mail.com,587.00,INBOX,Drafts,Sent
counsellor.com,imap.mail.com,995.00,smtp.mail.com,587.00,INBOX,Drafts,Sent
cyberservices.com,imap.mail.com,995.00,smtp.mail.com,587.00,INBOX,Drafts,Sent
deliveryman.com,imap.mail.com,995.00,smtp.mail.com,587.00,INBOX,Drafts,Sent
diplomats.com,imap.mail.com,995.00,smtp.mail.com,587.00,INBOX,Drafts,Sent
hostgator,gator4171.hostgator.com,993.00,gator4171.hostgator.com,587.00,INBOX,INBOX.Sent,INBOX.Drafts
teknik.io,mail.teknik.io,993.00,mail.teknik.io,587.00,,,
yandex.com,imap.yandex.com,993.00,smtp.yandex.com,465.00,,,
outlook.com,imap-mail.outlook.com,993.00,smtp-mail.outlook.com,587.00,,,
hotmail.com,imap-mail.outlook.com,993.00,smtp-mail.outlook.com,587.00,,,
gmail.com,imap.google.com,993.00,smtp.gmail.com,587.00,INBOX,[Gmail].Drafts,[Gmail].Sent Mail
cock.li,mail.cock.li,993.00,mail.cock.li,587.00,INBOX,Drafts,Sent
airmail.cc,mail.cock.li,993.00,mail.cock.li,587.00,INBOX,Drafts,Sent
8chan.co,mail.cock.li,993.00,mail.cock.li,587.00,INBOX,Drafts,Sent
redchan.it,mail.cock.li,993.00,mail.cock.li,587.00,INBOX,Drafts,Sent
420blaze.it,mail.cock.li,993.00,mail.cock.li,587.00,INBOX,Drafts,Sent
aaathats3as.com,mail.cock.li,993.00,mail.cock.li,587.00,INBOX,Drafts,Sent
cumallover.me,mail.cock.li,993.00,mail.cock.li,587.00,INBOX,Drafts,Sent
dicksinhisan.us,mail.cock.li,993.00,mail.cock.li,587.00,INBOX,Drafts,Sent
loves.dicksinhisan.us,mail.cock.li,993.00,mail.cock.li,587.00,INBOX,Drafts,Sent
wants.dicksinhisan.us,mail.cock.li,993.00,mail.cock.li,587.00,INBOX,Drafts,Sent
dicksinmyan.us,mail.cock.li,993.00,mail.cock.li,587.00,INBOX,Drafts,Sent
loves.dicksinmyan.us,mail.cock.li,993.00,mail.cock.li,587.00,INBOX,Drafts,Sent
wants.dicksinmyan.us,mail.cock.li,993.00,mail.cock.li,587.00,INBOX,Drafts,Sent
goat.si,mail.cock.li,993.00,mail.cock.li,587.00,INBOX,Drafts,Sent
horsefucker.org,mail.cock.li,993.00,mail.cock.li,587.00,INBOX,Drafts,Sent
national.shitposting.agency,mail.cock.li,993.00,mail.cock.li,587.00,INBOX,Drafts,Sent
nigge.rs,mail.cock.li,993.00,mail.cock.li,587.00,INBOX,Drafts,Sent
tfwno.gf,mail.cock.li,993.00,mail.cock.li,587.00,INBOX,Drafts,Sent
cock.lu,mail.cock.li,993.00,mail.cock.li,587.00,INBOX,Drafts,Sent
cock.email,mail.cock.li,993.00,mail.cock.li,587.00,INBOX,Drafts,Sent
firemail.cc,mail.cock.li,993.00,mail.cock.li,587.00,INBOX,Drafts,Sent
hitler.rocks,mail.cock.li,993.00,mail.cock.li,587.00,INBOX,Drafts,Sent
getbackinthe.kitchen,mail.cock.li,993.00,mail.cock.li,587.00,INBOX,Drafts,Sent
memeware.net,mail.cock.li,993.00,mail.cock.li,587.00,INBOX,Drafts,Sent
cocaine.ninja,mail.cock.li,993.00,mail.cock.li,587.00,INBOX,Drafts,Sent
waifu.club,mail.cock.li,993.00,mail.cock.li,587.00,INBOX,Drafts,Sent
rape.lol,mail.cock.li,993.00,mail.cock.li,587.00,INBOX,Drafts,Sent
nuke.africa,mail.cock.li,993.00,mail.cock.li,587.00,INBOX,Drafts,Sent

+ 26
- 0
autoconf/mutt_profile Просмотреть файл

@@ -0,0 +1,26 @@
# vim: filetype=muttrc
# muttrc file for account $title
set realname = "$realname"
set from = "$fulladdr"
set smtp_url = "smtp://$fulladdr@$smtp:$sport/"
set sendmail = "/usr/bin/msmtp -a $title"
set folder = "~/.mail/$title"
set header_cache = ~/.config/mutt/$title/cache/headers
set message_cachedir = ~/.config/mutt/$title/cache/bodies
set certificate_file = ~/.config/mutt/$title/certificates
source "~/.config/mutt/credentials/getmuttpass $title |"

set spoolfile = "+$spoolfile"
set record = "+$record"
set postponed = "+$postponed"


set mbox_type = Maildir
set ssl_starttls = yes
set ssl_force_tls = yes

bind index,pager g noop
bind index gg first-entry
macro index,pager gi "<change-folder>=$spoolfile<enter>" "Go to inbox"
macro index,pager gs "<change-folder>=$record<enter>" "Go to sent"
macro index,pager gd "<change-folder>=$postponed<enter>" "Go to drafts"

+ 6
- 0
autoconf/offlineimap_header Просмотреть файл

@@ -0,0 +1,6 @@
[general]
accounts =
starttls = yes
ssl = yes
pythonfile = ~/.config/mutt/credentials/imappwd.py


+ 18
- 0
autoconf/offlineimap_profile Просмотреть файл

@@ -0,0 +1,18 @@
[Account $title]

localrepository = $title-local
remoterepository = $title-remote

[Repository $title-remote]
type = $type
remoteuser = $fulladdr
sslcacerfile = /etc/ssl/cets/ca-certificates.crt
remotepasseval = mailpasswd("$title")
remotehost = $imap
port = $iport
folderfilter = lambda foldername: foldername not in ['[Gmail]/All Mail']
sslcacertfile = /etc/ssl/certs/ca-certificates.crt

[Repository $title-local]
type = Maildir
localfolders = ~/.mail/$title

+ 4
- 0
credentials/getmuttpass Просмотреть файл

@@ -0,0 +1,4 @@
#!/bin/bash
pass=$(gpg -d -q ~/.config/mutt/credentials/$1.gpg)
echo set smtp_pass=\"$pass\"
echo set imap_pass=\"$pass\"

+ 11
- 0
credentials/imappwd.py Просмотреть файл

@@ -0,0 +1,11 @@
import os.path
import subprocess
home = os.path.expanduser("~")
def mailpasswd(acct):
acct = os.path.basename(acct)
path = "%s/.config/mutt/credentials/%s.gpg" % (home,acct)
args = ["gpg", "--use-agent", "--quiet", "--batch", "-d", path]
try:
return subprocess.check_output(args).strip()
except subprocess.CalledProcessError:
return ""

+ 17
- 0
manual.sh Просмотреть файл

@@ -0,0 +1,17 @@
# The stuff for manually putting in server settings.
# Will be added to main script as option eventually.
remotehost=$(\
dialog --inputbox "Insert the IMAP server for your email provider (excluding the port number)" 10 60 \
3>&1 1>&2 2>&3 3>&- \
)

dialog --inputbox "What is your server's IMAP port number? (Usually 993)" 10 60

smtpserver=$(\
dialog --inputbox "Insert the SMTP server for your email provider (excluding the port number)" 10 60 \
3>&1 1>&2 2>&3 3>&- \
)
smtpport=$(\
dialog --inputbox "What is your server's SMTP port number? (Usually 587 or 465)" 10 60
3>&1 1>&2 2>&3 3>&- \
)

+ 80
- 0
mutt_install.sh Просмотреть файл

@@ -0,0 +1,80 @@
#!/bin/bash
muttdir="$HOME/Repos/email-mutt-offline/"
mkdir -p ~/.config/mutt/credentials

# Email for GPG
youremail=$(\
dialog --title "Luke's mutt/offlineIMAP password wizard" --inputbox "Insert the email address with which you originally created your key pair. This is NOT necessarily the email you want to configure." 10 60 \
3>&1 1>&2 2>&3 3>&- \
)

# Get email address
fulladdr=$(\
dialog --title "Luke's mutt/offlineIMAP autoconfig" --inputbox "Insert your full email address." 10 60 \
3>&1 1>&2 2>&3 3>&- \
)

# Check to see if domain is in domain list
serverinfo=$(cat autoconf/domains.csv | grep -w ^${fulladdr##*@})
if [ -z "$serverinfo" ]; then echo No suitable match. && exit; fi

# Read in server data as variables
IFS=, read service imap iport smtp sport spoolfile postponed record <<EOF
$serverinfo
EOF
clear

realname=$(\
dialog --title "Luke's mutt/offlineIMAP autoconfig" --inputbox "Enter the full name you'd like to be identified by on this email account." 10 60 \
3>&1 1>&2 2>&3 3>&- \
)

title=$(\
dialog --title "Luke's mutt/offlineIMAP autoconfig" --inputbox "Give a short, one-word name for this email account that will differentiate it from other email accounts." 10 60 \
3>&1 1>&2 2>&3 3>&- \
)


# Sets the repo type and other variables for the sed regex.
if [[ "$service" == "gmail.com" ]];
then
type="Gmail"
delet="remotehost"
else
type="IMAP"
delet="Gmail]\/"
fi

# The replacements
replacement="
s/\$realname/$realname/g;
s/\$title/$title/g;
s/\$fulladdr/$fulladdr/g;
s/\$imap/$imap/g;
s/\$iport/$iport/g;
s/\$smtp/$smtp/g;
s/\$sport/$sport/g;
s/\$spoolfile/$spoolfile/g;
s/\$postponed/$postponed/g;
s/\$record/$record/g;
s/\$type/$type/g;
/$delet/d"


addAccount() {
if [ ! -f ~/.offlineimaprc ]; then cp "$muttdir"autoconf/offlineimap_header ~/.offlineimaprc; fi
cat "$muttdir"autoconf/offlineimap_profile | sed -e "$replacement" >> ~/.offlineimaprc
# Add the mutt profile.
cat "$muttdir"autoconf/mutt_profile | sed -e "$replacement" > "$muttdir"accounts/$title.muttrc
# Add on offlineimaprc sync list.
sed -i "s/^accounts =.*[a-zA-Z]$/&, $title/g;s/^accounts =$/accounts = $title/g" ~/.offlineimaprc ;}

addAccount

dialog --title "Luke's mutt/offlineIMAP password wizard" --passwordbox "Enter the password for the \"$title\" account." 10 60 2> /tmp/$title
gpg -r $youremail --encrypt /tmp/$title
shred -u /tmp/$title && echo "Password encrypted and memory shredded."
mv /tmp/$title.gpg ~/.config/mutt/credentials/

echo Done lmao.
exit

+ 111
- 0
offlineimap Просмотреть файл

@@ -0,0 +1,111 @@
[general]
accounts = luke, gmail
#accounts = luke, gmail, gkulade, kulade, evenor
starttls = yes
ssl = yes
autorefresh = 1
pythonfile = ~/.config/mutt/credentials/imappwd.py


#######
[Account gmail]

localrepository = gmail-local
remoterepository = gmail-remote

[Repository gmail-remote]
type = Gmail
remoteuser = luxmyth@gmail.com
remotepasseval = mailpasswd("gmail")
folderfilter = lambda foldername: foldername not in ['[Gmail]/All Mail', '[Gmail]/Chats', '[Gmail].Trash', 'Trump', 'ugaroml', 'SMS']
#folderfilter = lambda foldername: foldername in ['INBOX', 'lingcircle', "[Gmail].Sent Mail", '[Gmail].Drafts']
sslcacertfile = /etc/ssl/certs/ca-certificates.crt

[Repository gmail-local]
type = Maildir
localfolders = ~/.Mail/Gmail

#######

[Account luke]

localrepository = luke-local
remoterepository = luke-remote

[Repository luke-remote]
type = IMAP
remoteuser = luke@lukesmith.xyz
remotepasseval = mailpasswd("luke")
remotehost = gator4171.hostgator.com
folderfilter = lambda foldername: foldername in ['INBOX', 'INBOX.Sent', 'INBOX.Drafts']
sslcacertfile = /etc/ssl/certs/ca-certificates.crt

[Repository luke-local]
type = Maildir
localfolders = ~/.Mail/Luke

[Account kulade]
localrepository = kulade-local
remoterepository = kulade-remote

[Repository kulade-remote]
type = IMAP
remoteuser = kulade@cock.li
remotepasseval = mailpasswd("kulade")
sslcacertfile = /etc/ssl/certs/ca-certificates.crt
remotehost = mail.cock.li

[Repository kulade-local]
type = Maildir
localfolders = ~/.Mail/kulade
#######
[Account gkulade]

localrepository = gkulade-local
remoterepository = gkulade-remote

[Repository gkulade-remote]
type = Gmail
remoteuser = kulade@gmail.com
remotepasseval = mailpasswd("gkulade")
folderfilter = lambda foldername: foldername not in ['[Gmail]/All Mail', 'SMS', 'Call log']
sslcacertfile = /etc/ssl/certs/ca-certificates.crt

[Repository gkulade-local]
type = Maildir
localfolders = ~/.Mail/gkulade

#[Account arizona]
#
#localrepository = arizona-local
#remoterepository = arizona-remote
#
#[Repository arizona-remote]
#type = IMAP
#remoteuser = lukesmith@email.arizona.edu
#remotehost = mail.catnet.arizona.edu
#port = 993
##folderfilter = lambda foldername: foldername not in ['[Gmail]/All Mail', '[Gmail]/Chats', '[Gmail].Trash', 'Trump', 'ugaroml', 'SMS']
#folderfilter = lambda foldername: foldername in ['INBOX', 'lingcircle', '[Gmail].Sent Mail', '[Gmail].Drafts']
#sslcacertfile = /etc/ssl/certs/ca-certificates.crt
#
#[Repository arizona-local]
#type = Maildir
#localfolders = ~/.Mail/Arizona

[Account evenor]
localrepository = evenor-local
remoterepository = evenor-remote

[Repository evenor-remote]

type = IMAP
remoteuser = evenor@teknik.io
remotepasseval = mailpasswd("evenor")
remotehost = mail.teknik.io
port = 993
sslcacertfile = /etc/ssl/certs/ca-certificates.crt

[Repository evenor-local]
type = Maildir
localfolders = ~/.Mail/Evenor

+ 20
- 0
removeaccount.sh Просмотреть файл

@@ -0,0 +1,20 @@
#!/bin/sh
muttdir="$HOME/Repos/email-mutt-offline/"

# This script will remove an account from ~/.offlineimaprc and the
# designated location in ~/.config/mutt/accounts.

# Feed the script the title of the account.

title=$1

removeAccount() { sed -ie "
/Account $title]/,/Account/{//!d}
/Account $title]/d
s/ $title\(,\|$\)//g
s/=$title\(,\|$\)/=/g
s/,$//g
" ~/.offlineimaprc
rm "$muttdir"accounts/$title.muttrc
echo $title deleted. ;}
removeAccount $title

+ 8
- 0
stat.sh Просмотреть файл

@@ -0,0 +1,8 @@
#!/bin/sh

# Gets all accounts used by offlineimaps.

cat ~/.offlineimaprc | grep "^accounts =" | sed -e 's/accounts =\( \)//g;s/\(,\) /\n/g;'
# Another option
# Get current accounts
#accountsline=$(cat ~/.offlineimaprc | grep ^accou | sed 's/,//g')

Загрузка…
Отмена
Сохранить