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
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
selectively attachments, after asking the user,
(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).
kmailpt is also able to remove/detach attachments from gpg encrypted
emails, and to store these emails decrypted.
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
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
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
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)
all attachments (no user interaction)
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
(no user interaction)
gpg emails (to store them decrypted) (new
-m add the
detached/removed file md5 to the message
-s add the
detached/removed file size to the message
gpg-agent (don't ask for gpg passphrase) (new
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
- 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
- to remove all attachments:
(warning: this will remove all attachments
without any prompt)
- to ask the user which attachment to remove:
- to detach attachments:
- to store the email decrypted:
- Note: you
can also add the following options:
-m to add the
md5 sum of the file
to the disclaimer
to add the file size to the
to store the result decrypted
to make use
- Advanced tab
- uncheck "Apply this filter to incoming messages" and
this filter to sent messages"
- check "Apply this filter on manual filtering", "If
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
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
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
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
with the new icon in the toolbar, the contextual menu, or the keyboard
- New features
- New icons thanks to Rüdiger Härtel
- Handle gpg encrypted emails:
- Now able to remove/detach attachments within a gpg
- 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.
- 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)
v0.1. First public version.
- 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!)
© Jean-Christophe Cardot <jice