mail labeling
Following the previous post, I’ve been playing around with labeling my email. Mutt has really good labeling support, mostly because of its flexibility. With it, I can pretty much do anything I need using labels (add, delete, modify, limit views to a given label etc), so it has become my primary email client these days.
I used to use Kontact, and I still like some of its functionality (like setting up search folders), but not being able to edit and add labels make it hard to use. It’s also not that stable when you’re using imap. Looking forward to trying it out again when KDE 4 turns stable. Hopefully, it is more stable there.
Being, the lazy bum that I am, I really don’t want to manually add labels to email from people I know when the computer can do as good a job as I can. Enter maildrop. One thing that I noticed was when I wanted to the system to add multiple labels to a given email because multiple people was on the mail list. I therefore wrote the following maildrop rule (procmail users can probably write a similar rule for their system):
# Get address from the From, To, and Cc line
foreach /^(From|To|Cc): .*/
{
foreach (getaddr $MATCH) =~ /.+/
{
ADDR=tolower($MATCH)
# check if the address is in the label file
# label file has a key/value pairing looking like this
# example@example.com exlabel
# where first part is the address and second part is the label
TMPLABEL=`grep $ADDR labels`
if ( $RETURNCODE == 0 )
{
# if message already has a label, keep it
LABEL = `echo $TMPLABEL | cut -d' ' -f2`
if ( /^X-Label: (.*)/ )
{
xfilter "/usr/bin/reformail -I 'X-Label: $MATCHLABEL, $LABEL'"
}
else
{
xfilter "/usr/bin/reformail -I 'X-Label: $LABEL'"
}
}
}
}
So far, it’s been working really well.