KMail Power Tools
[fr] désolé mais je manque de temps pour
traduire cette page en français.
What is it?
KMail Power Tools is meant to be a suite of enhancements to
KMail and may be other mail user agents.
It is currently composed of only one (perl) script that acts
as a
filter (take input from stdin, outputs the modified mail to stdout),
adds dialog boxes to kmail, and allows the user to:
- remove all
attachments from an email (no user
interaction),
- remove
selectively attachments, after asking the user,
- detach
(i.e. save then remove) any
attachment to a
directory chosen by the user,
hence reducing the size of your mailbox, while allowing you to
backup important attached files.
All these actions are logged within a sentence (called
"disclaimer") in the mail
body. Plus when you detach a file, you don't lose the link between your
email and the file! (see below).
Note 1:
kmailpt is also able to remove/detach attachments from gpg encrypted
emails, and to store these emails decrypted.
Note 2:
removing and detaching is already supported by Thunderbird, but my
favourite mailer program is KMail, then... ;-)
How it works
KMail allows the definition of filters (like any other email
program),
but you can define filters:
- which are launched manually,
- which can be programs reading your email on stdin and
outputing the result on stdout (or "pipe through").
So I had the idea to use this in order to enhance KMail, and
allow it
to remove and detach attachments: kmailpt will read and interpret the
email (thank you Perl MIME::Parser), then depending on the command line
switches, popup a dialog box to ask the user for a directory where to
save attachments, and ask
him which attachment to remove/detach (thank you Kdialog!).
Also, the sentence "[Attachment
removed by jice (26/02/2007 20:33:01): bill.zip]" will be
added to the mail body. When you detach an email, it will add a similar
sentence, and if the mail body is html, you will even get a link to the
new location of the file: "[Attachment
saved by jice (26/02/2007 20:36:17) to heavenly.gif]",
on which you can even click in order to view the detached file. For
text/plain messages, the sentence will be something like: "[Attachment
saved by jice (26/02/2007 20:36:17) to
file:///home/jice/Images/heavenly.gif]" (unfortunately,
although kmail renders http:// or ftp:// urls as links,
file:// urls are not (yet?) made clickable - please vote for bug 60265 on bugs.kde.org).
Should you want to know the currently available command line
switches, here is the help:
KMail power tools 0.3
(c) 2007 Jean-Christophe Cardot <kmailpt <at> cardot.net>
This program is distributed under the terms of the GPL licence
Usage: kmailpt [action] [options]
kmailpt takes an email on stdin, performs actions based
on this mail, then output the resulting email on stdout.
Actions: (one among these options is mandatory)
-a remove
all attachments (no user interaction)
-q ask
which attachment to remove
-d [dir] detach the attachments (save and remove).
When given the optional argument directory,
detaches all the attachments to this directory (new
optional argument)
(no user interaction)
-g decrypt
gpg emails (to store them decrypted) (new
option)
Options:
-m add the
detached/removed file md5 to the message
-s add the
detached/removed file size to the message
-n
multiline disclaimer
-p use
gpg-agent (don't ask for gpg passphrase) (new
option)
-h prints
this help
Screenshots

The new icons in the
toolbar (
&
), along with
the result (see the mail body) of a removed file
(get rid from those *$&# smileys from Incredim4il ;-)

KMailPT asking where to
store the detached files

KMailPT asking which
attachment to remove or detach

The result of a detached
file, within the mail body (see in the status bar the hyperlink to the
new location of the file; you can click on the link to view the file.)
How to install
- Pre-requisites: Perl packages MIME::Parser,
MIME::WordDecoder & GnuPG::Interface (new optional
requirement since 0.3), Kdialog
Note: in Mandriva, MIME::Parser resides in the 'perl-MIME-tools'
package, whereas in Debian based distros, it can be found in the
'libmime-perl' package.
- Uncompress the tarball in a temporary directory.
- Install the files system wide by: make install
(as root). This will copy kmailpt.pl to /usr/local/bin, and the icons to /usr/share/icons/.
- You may repeat 4 times this step:
- Create a new filter in kmail (Settings/Configure
filters) with the following settings:
- Filter Criteria
- Select "Match all the following"
- <any header> [Contains] .
(yes dot, this
will match any mail)
- Filter Actions: choose [Pipe Through], then
use:
- to remove all attachments:
/usr/local/bin/kmailpt.pl
-a
(warning: this will remove all attachments
without any prompt)
- to ask the user which attachment to remove:
/usr/local/bin/kmailpt.pl
-q
- to detach attachments:
/usr/local/bin/kmailpt.pl
-d
- to store the email decrypted:
/usr/local/bin/kmailpt.pl
-g
- Note: you
can also add the following options:
-m to add the
md5 sum of the file
to the disclaimer
-s
to add the file size to the
disclaimer
-g
to store the result decrypted
-p
to make use
of gpg-agent.
- Advanced tab
- uncheck "Apply this filter to incoming messages" and
"Apply
this filter to sent messages"
- check "Apply this filter on manual filtering", "If
this
filter matches, stop processing here", "Add this filter to the Apply
Filter menu" and "Additionaly add this filter to the toolbar"
- choose a beautiful Icon for this filter. For example,
for my "remove attachments" filter, I chose "/usr/share/icons/attach_delete.png", and for my
"detach
attachments" filter, I chose "/usr/share/icons/attach_save.png". For my "decrypt email" filter, I found decrypted.png.
- you may also select a keyboard shortcut to run it
- [Rename] this filter to "Remove all attachments",
"Remove attachments", "Detach attachments" or "Decrypt email" depending on the
filter
action you entered.
- Press [OK] ;-)
How to upgrade
- If you already had installed the version 0.1 or 0.2, then
you just need
to unpack the archive, then type (as root) make install (this will
simply copy kmailpt.pl to /usr/local/bin)
- If you created a "Remove all attachments" filter and
upgrade
from version 0.1, then add the -a option to the command line, else it
will do nothing.
How to use
Just select the email in KMail, then call the
appropriate
filter,
with the new icon in the toolbar, the contextual menu, or the keyboard
shortcut.
News
- 28/5/2007:
v0.3
- New features
- New icons thanks to Rüdiger Härtel
- Handle gpg encrypted emails:
- Now able to remove/detach attachments within a gpg
encrypted email
- New command line option -g to tell kmailpt to leave
the resulting email decrypted
- Command line option -p tells KmailPT to use gpg-agent
instead of asking the passphrase
- option -d now takes an optional argument to tell it
from the command line where to store the detached files.
When this argument is present, every file is detached to the given
destination (no dialog box prompts for this).
- Bug corrections
- The disclaimer was added even to text/plain and
text/html attached files. This is fixed.
- 20/3/2007:
v0.2
- New features:
- now, when you call kmailpt without no option, it will
do nothing. Use '-a' to remove all attachments (old behaviour)
- added options -m & -s to add the md5 and the
size to the disclaimer
- added option -n to have the disclaimer splitted on more
than one line
- when the destination file already exist, automatically
rename the detached file (file-1.ext, file-2.ext, s.o.)
- replaced ~/tmp by ~/.kmailpt to store temporary files
- Bug corrections (see the Changelog)
- 4/3/2007:
v0.1. First public version.
Files
To do
- enable i18n
- create a graphical interface for easy configuration and
automatic integration within Kmail
- edit manually the mail contents (headers, subject, body)
- allow parameters in the -d optional arguments (taken from the email header, like From, Message-id...)
- add a command line option to resolve symbolic links in the disclaimer (i.e. print the "real" path)
- fix known bugs
- better handling of gpg emails (for now kmailpt does not handle gpg emails when they are encapsulated within another email)
- print the disclaimer only in the right text and/or html part
(today it's printed in any inline textual part instead of the part
where the attachment was belonging)
- packages for your favourite distribution (please help me!)
Links
© Jean-Christophe Cardot <jice
chez
cardot point
net> 2007