Text based email example

From ParabolaWiki
Jump to: navigation, search

I use a combination of Mutt, Getmail, Procmail, Bogofilter, GnuPG, and NotMuch to handle my email. Here are some key config files

These leave the USER, that is me, in control of my email. No viruses, no java, no html, no images unless I want to open them. The text and nothing but the text so I can breeze through my emails.

I choose to use POP because I don't keep email on the server. IMAP works equally well

I use Maildir because each email is its own file, which has advantages for archiving, searching and storage. Other formats are fine too.

Here's what's happening behind the scenes:

  • Getmail fetches emails from 1 or more email servers/accounts
  • It's passed through Bogofilter for spam detection
  • Procmail then routes definite spam to spam, unsure to a mailbox for review, other mail to 1 or more labels/filters/mailboxes depending on user preferences
  • Mutt where a user reads/sends email
  • GnuPG providing signing and encryption for emails
  • NotMuch for archive and searching

1 muttrc

#muttrc of charles roth, feel free to use
#general configurations

set mbox_type=Maildir              #I use Maildir because 1 email = 1 file, flexible for backups, search and archiving
set folder=~/Maildir               #Where's the mail
set spoolfile=+/inbox              #the main "inbox"
set record=+/sent         
set mbox=+/archive                 #after I view and email, and if I don't delete it or save to a folder, then move it to archive
set postponed=+/postponed
set move=yes
set delete=yes                          #delete without prompting
set mime_forward=yes
set mime_forward_rest=yes
alternative_order text/enriched text/plain text/html
source $MAILCONF~/.mutt/mutt-colors

#set sig_on_top           # Don't do this on mailing lists!
set mail_check=90        # check for new mail every 90 seconds
set timeout=15           # after 15 secs of no keypresses, start checking for new mail
set reverse_name         # Reply with the address used in the TO/CC header
set ascii_chars=yes      # Use ASCII arrows
set reverse_realname=yes # Reply with the name used in FROM
set reverse_alias=yes
set fast_reply="yes"
set confirmappend=no     # Confirm when appending messages to an existing mailbox?
set pager_index_lines=5  # Show 5 message headers from your message index above an email you are reading
# h will take you to the folder list in the index
macro index     h "c?t"
auto_view text/html

# emacs with special startup settings -- you might choose nano or vim here
  set editor=emacsclient
  set pager=emacsclient

# directories and commands
set alias_file          = ~/.mutt/alias                         # alias file
set sort_alias= alias
set reverse_alias=yes
source $alias_file

ignore *
unignore from date subject to cc
unignore organization organisation x-mailer: x-newsreader: x-mailing-list:
unignore posted-to:

set certificate_file    = ~/.mutt/certificates
set mailcap_path        = ~/.mutt/mailcap                       # entrys for filetypes
set signature           = ~/.mutt/muttsig                          # my signature file
set tmpdir              = ~/.mutt/temp  

set realname='Your Name'

#sending mail
set from = "user@domain.net"
my_hdr X-URL: http://encyclomundi.org/wiki/User:Encyclom/
set smtp_url="smtp://user:password@domain.net"

#GnuPG lots of automation for detecting and checking GnuPG
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 D9F18914 -- -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 D9F18914 -- -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" 
set pgp_autosign=yes
set pgp_sign_as=12345678 #what's your key id?
set pgp_replyencrypt=yes
set pgp_timeout=1800
set pgp_good_sign="^gpg: Good signature from"
set pgp_verify_sig=yes

#allows notmuch search for an email from within mutt
macro index <F8> \
                 "<enter-command>unset wait_key<enter><shell-escape>/usr/bin/mutt-notmuch --prompt search<enter><change-folder-readonly>~/.cache/mutt_results<enter>" \
                 "search mail (using notmuch)"
           macro index <F9> \
                 "<enter-command>unset wait_key<enter><pipe-message>/usr/bin/mutt-notmuch thread<enter><change-folder-readonly>~/.cache/mutt_results<enter><enter-command>set wait_key<enter>" \
                 "search and reconstruct owning thread (using notmuch)"

macro index G "!getmail -vn" "Invoke getmail" 


macro index s "<enter-command>unset wait_key\n<tag-prefix><pipe-entry>bogofilter -MSn\n<enter-command>set wait_key\n<tag-prefix><save-entry>"
macro pager s "<enter-command>unset wait_key\n<pipe-entry>bogofilter -MSn\n<enter-command>set wait_key\n<save-entry>"

macro index r "<enter-command>unset wait_key\n<tag-prefix><pipe-entry>bogofilter -Mn\n<enter-command>set wait_key\n<tag-prefix><reply>"
macro pager r "<enter-command>unset wait_key\n<pipe-entry>bogofilter -Mn\n<enter-command>set wait_key\n<reply>"

macro index g "<enter-command>unset wait_key\n<tag-prefix><pipe-entry>bogofilter -Mn\n<enter-command>set wait_key\n<tag-prefix><group-reply>"
macro pager g "<enter-command>unset wait_key\n<pipe-entry>bogofilter -Mn\n<enter-command>set wait_key\n<group-reply>"

macro index l "<enter-command>unset wait_key\n<tag-prefix><pipe-entry>bogofilter -Mn\n<enter-command>set wait_key\n<tag-prefix><list-reply>"
macro pager l "<enter-command>unset wait_key\n<pipe-entry>bogofilter -Mn\n<enter-command>set wait_key\n<list-reply>"

macro index X "<enter-command>unset wait_key\n<tag-prefix><pipe-entry>bogofilter -MNs\n<enter-command>set wait_key\n<tag-prefix><delete-message>"
macro pager X "<enter-command>unset wait_key\n<pipe-entry>bogofilter -MNs\n<enter-command>set wait_key\n<delete-message>"

#these are the folders that mutt checks for new mail. Procmail moves mail from the server inbox into these 3.
mailboxes "+inbox"
mailboxes "+unsure-bogofilter"
mailboxes "+micro"

2 getmailrc

#for parlementum.net mail
verbose = 0
delete = true
message_log = ~/.getmail/log
message_log_verbose = true

type = SimplePOP3SSLRetriever
server = parlementum.net
username = user
port = 995
password = password
delete_dup_msgids = true

#getmail direct steps
#type = Maildir
#path = ~/Maildir/encyclomundi/
#move_on_delete = Trash

#via procmail
type = MDA_external
path = /usr/bin/procmail

3 procmailrc

MAILDIR=$HOME/Maildir/      # Make sure this directory exists!	

# tumblr
* ^From:.*tumblr.com

# google +
* ^From:.*plus.google.com

# parlementum.net
* ^From:.*parlementum.net

# twitter
* ^From:.*twitter.com

# parabola daemon
* ^From:.*lions.dreamhost.com

# facebook
* ^From:.*facebookmail.com

# auto send public key
:0 h
* ^Subject:[    ]+\/(|send)[    ]+key pub\>.*
| mutt -s "Re: $MATCH" `formail -rtzxTo:` <~/cer.asc

# filter mail through bogofilter, tagging it as Ham, Spam, or Unsure,
           # and updating the wordlist

           | bogofilter -u -e -p

           # if bogofilter failed, return the mail to the queue;
           # the MTA will retry to deliver it later
           # 75 is the value for EX_TEMPFAIL in /usr/include/sysexits.h

           { EXITCODE=75 HOST }

           # file the mail to spam-bogofilter if it's spam.

           * ^X-Bogosity: Spam, tests=bogofilter

           # file the mail to unsure-bogofilter
           # if it's neither ham nor spam.

           * ^X-Bogosity: Unsure, tests=bogofilter

           # With this recipe, you can train bogofilter starting with an empty
           # wordlist.  Be sure to check your unsure-folder regularly, take the
           # messages out of it, classify them as ham (or spam), and use them to
           # train bogofilter.


  • sort normal notifications from networks to the micro mailbox for later review
  • sort actual spam to spam mailbox
  • sort maybe spam to unsure mailbox for my review

4 Additional Resources