eMail Optimizations
Here I put some ideas and scripts roughly clustered around email handling.
procmail: filter incoming mail by address book
One of my favorite procmail recepies: It puts your mail in a folder depending on in which (mutt-) address book you keep the sender in:
For each address book (here: uni
) you need on entry like the following in your .procmailrc
:
2 * ? echo ${SENDER} | grep -is -F "`eaextr ~/.mail_aliases.uni`"
3 groups.uni/
4
additionally you need the following perl script as eaextr
in your path:
2 s/^.*<(.*)>.*$/$1/;
3 print $1."\n";
4
Correct salutation added automatically
Ein wenig komplizierter: Die Anrede wird automatisch generiert, je nachdem an
wen man eine E-Mail schreibt. Zum Beispiel steht in der E-Mail an
max.mustermann@eliteuni.de
gleich als erstes “Hallo Herr Prof. Mustermann,”.
Das geht so:
This is a bit more complex: We generate the salutation at the beginning of the
mail, depending on the recipient. For example, you have a mail to
max.mustermann@eliteuni.de
, then your mail will start with “Hallo Mr.
Mustermann”.
- In
.muttrc
add the lineset editor="~/bin/vim-mutt"
- The file
~/bin/vim-mutt
will now be called as your editor. In it, you can define abbreviations, tell vim where to place the cursor at the correct position, and call the script which generates the salutation. Finally, we callvim
:1 # /usr/bin/vim-mutt
2 # define aliases for the people in your address books
3 sed -e 's/alias/iab/' ~/.mail_aliases* > ~/.vim_mutt_aliases
4
5 # let vim create the salutation
6 echo "silent! %!~/bin/mailtmpl.pl" >> ~/.vim_mutt_aliases
7
8 # place a mark above your name (which i assume is at the end
9 # of your standard mail template), so that you can skip to it
10 # if you do not have a makro to jump to <++> tags, delete this line
11 echo 'silent! exe "normal /^\\s*Your Name^Mkko<++>ESCgg/^$^M"' >> ~/.vim_mutt_aliases
12
13 # call vim
14 exec /usr/bin/vim -S ~/.vim_mutt_aliases $@
15
- We now define a list
.mail_titles
, in which we place exceptions to the rule (first name only). Each line contains a pattern and a salutation type.max.muster@stanford hprof meier herr schulze herr tina.mustermann frau my.mom@web.de Mom
Later,hprof
will be replaced byHerr Prof. {Last name}
, while “Mom” stays as it is. - We now need the script which generates the salutation:
mailtmpl.pl (1.02 KiB).
It reads the (empty) mail until it finds the
To:
line and tries to match it with the exceptions defined above. If it fails, it usesHallo {First Name}
.
Loosely related fun stuff
You might want to check out the following:
- Echelon is a perl script which lets you add funny words to your emails to confuse people who do pattern-based email spying