KMail custom filter actions?
Concerning the recent threads on spam handling: I would like to have a KMail filter action which would enable me to forward a message (i.e. spam) to an address (i.e. SpamCop) *as an attachment*. By default, there's only a "forward" action, no "forward as attachment" filter action. How would one go about creating such an action, if at all possible (apart from modifying KMail source)? -- !++ ! Lennart Börjeson ! Partner, Developer ! Cinnober Financial Technology AB ! Industrigatan 2A ! S-112 46 STOCKHOLM ! Sverige/Sweden/Schweden/Suède ! mailto:Lennart.Borjeson@cinnober.com ! phone:+46-8-50304700 ! fax:+46-8-50304701 ! http://www.cinnober.com !--
On Tuesday 17 September 2002 15:19, Lennart Börjeson wrote:
Concerning the recent threads on spam handling:
I would like to have a KMail filter action which would enable me to forward a message (i.e. spam) to an address (i.e. SpamCop) *as an attachment*. By default, there's only a "forward" action, no "forward as attachment" filter action.
How would one go about creating such an action, if at all possible (apart from modifying KMail source)?
The only way I see it being possible is to set the filter to pipe through a command. You could use a perl script that writes the email to a file. That's the easy part (for me, anyway). You can then use that file as the attachment. This worked for me, but I don't know how you would get it as an attachment to an email other than building mime components yourself. Regards, jimmo -- --------------------------------------- "Be more concerned with your character than with your reputation. Your character is what you really are while your reputation is merely what others think you are." -- John Wooden --------------------------------------- Be sure to visit the Linux Tutorial: http://www.linux-tutorial.info --------------------------------------- NOTE: All messages sent to me in response to my posts to newsgroups or forums are subject to reposting.
* James Mohr (suse_mailing_list@jimmo.com) [020917 09:53]:
This worked for me, but I don't know how you would get it as an attachment to an email other than building mime components yourself.
mmj has a handy little program named biabam (it's in the distribution) that can do this for you. I don't know if kmail can write to a pipe but if so something like | (>spam;biabam spam someone@spamcop.net) should work. If it can't write to a pipe you probably should get a more user-friendly mailer. -- -ckm
On Tuesday 17 September 2002 19:38, Christopher Mahmood wrote:
* James Mohr (suse_mailing_list@jimmo.com) [020917 09:53]:
This worked for me, but I don't know how you would get it as an attachment to an email other than building mime components yourself.
mmj has a handy little program named biabam (it's in the distribution) that can do this for you. I don't know if kmail can write to a pipe but if so something like
| (>spam;biabam spam someone@spamcop.net)
should work.
If it can't write to a pipe you probably should get a more user-friendly mailer.
What I was getting at was a filter action which is actually called "pipe through". You give it the name of a program and kmail actually takes care of setting up as the end of the pipe. My test script was really simple: #!/usr/bin/perl open(OUT,">/tmp/filter.out"); while(<STDIN>){ print OUT $_; } close OUT; Email that matched the filter was simply written to /tmp/filter.out and at this point you can do whatever you wanted with it. Regards, jimmo -- --------------------------------------- "Be more concerned with your character than with your reputation. Your character is what you really are while your reputation is merely what others think you are." -- John Wooden --------------------------------------- Be sure to visit the Linux Tutorial: http://www.linux-tutorial.info --------------------------------------- NOTE: All messages sent to me in response to my posts to newsgroups or forums are subject to reposting.
Success!
I've combined these ideas into a perl script and let a KMail filter handle the
rest.
The actions I've specified are: 1) pipe through the perl script, 2) forward
the result, 3) move it to the wastebasket. An additional filter traps the
sent message and move it too to the wastebasket.
Perl script below:
$boundary="------------Boundary-00=_AFHLAKJHLAKJDGLAKFJDHG";
$name="SPAM!";
print "From: your.name@your.domain\n";
print "Subject: $name\n";
print "X-Mailer: KMail+Perl\n";
print "Message-ID:
On Tuesday 17 September 2002 19:38, Christopher Mahmood wrote:
* James Mohr (suse_mailing_list@jimmo.com) [020917 09:53]:
This worked for me, but I don't know how you would get it as an attachment to an email other than building mime components yourself.
mmj has a handy little program named biabam (it's in the distribution) that can do this for you. I don't know if kmail can write to a pipe but if so something like
| (>spam;biabam spam someone@spamcop.net)
should work.
If it can't write to a pipe you probably should get a more user-friendly mailer.
What I was getting at was a filter action which is actually called "pipe through". You give it the name of a program and kmail actually takes care of setting up as the end of the pipe. My test script was really simple:
#!/usr/bin/perl
open(OUT,">/tmp/filter.out"); while(<STDIN>){ print OUT $_; } close OUT;
Email that matched the filter was simply written to /tmp/filter.out and at this point you can do whatever you wanted with it.
Regards,
jimmo
-- !++ ! Lennart Börjeson ! Partner, Developer ! Cinnober Financial Technology AB ! Industrigatan 2A ! S-112 46 STOCKHOLM ! Sverige/Sweden/Schweden/Suède ! mailto:Lennart.Borjeson@cinnober.com ! phone:+46-8-50304700 ! fax:+46-8-50304701 ! http://www.cinnober.com !--
Cool! I had forget to mention that the unfiltered message gets sent back if there is no standard out on the pipe. Now I have a few ideas on what to do with this myself. ;-) On Wednesday 18 September 2002 09:43, Lennart Börjeson wrote:
Success!
I've combined these ideas into a perl script and let a KMail filter handle the rest.
The actions I've specified are: 1) pipe through the perl script, 2) forward the result, 3) move it to the wastebasket. An additional filter traps the sent message and move it too to the wastebasket.
Perl script below:
$boundary="------------Boundary-00=_AFHLAKJHLAKJDGLAKFJDHG"; $name="SPAM!"; print "From: your.name@your.domain\n"; print "Subject: $name\n"; print "X-Mailer: KMail+Perl\n"; print "Message-ID:
\n"; print "MIME-Version: 1.0\n"; print "Content-Type: Multipart/Mixed; boundary=\"$boundary\"\n"; print "\n"; print "\n"; print "--$boundary\n"; print "Content-Type: text/plain; charset=\"iso-8859-1\"\n"; print "Content-Transfer-Encoding: 8bit\n"; print "Subject: $name\n"; print "\n"; print "--$boundary\n"; print "Content-Type: message/rfc822; name=\"$name\"\n"; print "Content-Transfer-Encoding: 8bit\n"; print "Content-Description: $name\n"; print "\n"; while (<>) { chomp; print "$_\n"; } print "--$boundary--\n"; tisdagen den 17 september 2002 21.00 skrev James Mohr:
On Tuesday 17 September 2002 19:38, Christopher Mahmood wrote:
* James Mohr (suse_mailing_list@jimmo.com) [020917 09:53]:
This worked for me, but I don't know how you would get it as an attachment to an email other than building mime components yourself.
mmj has a handy little program named biabam (it's in the distribution) that can do this for you. I don't know if kmail can write to a pipe but if so something like
| (>spam;biabam spam someone@spamcop.net)
should work.
If it can't write to a pipe you probably should get a more user-friendly mailer.
What I was getting at was a filter action which is actually called "pipe through". You give it the name of a program and kmail actually takes care of setting up as the end of the pipe. My test script was really simple:
#!/usr/bin/perl
open(OUT,">/tmp/filter.out"); while(<STDIN>){ print OUT $_; } close OUT;
Email that matched the filter was simply written to /tmp/filter.out and at this point you can do whatever you wanted with it.
Regards,
jimmo
-- --------------------------------------- "Be more concerned with your character than with your reputation. Your character is what you really are while your reputation is merely what others think you are." -- John Wooden --------------------------------------- Be sure to visit the Linux Tutorial: http://www.linux-tutorial.info --------------------------------------- NOTE: All messages sent to me in response to my posts to newsgroups or forums are subject to reposting.
participants (3)
-
Christopher Mahmood
-
James Mohr
-
Lennart Börjeson