Bug 26021 - kmail filter enhancement request matching address book
Summary: kmail filter enhancement request matching address book
Status: RESOLVED FIXED
Alias: None
Product: kmail
Classification: Applications
Component: filtering (show other bugs)
Version: unspecified
Platform: unspecified Linux
: NOR wishlist
Target Milestone: ---
Assignee: kdepim bugs
URL:
Keywords:
: 44764 48279 72762 76561 (view as bug list)
Depends on:
Blocks:
 
Reported: 2001-05-22 15:03 UTC by David Bailey
Modified: 2007-09-14 12:17 UTC (History)
5 users (show)

See Also:
Latest Commit:
Version Fixed In:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description David Bailey 2001-05-22 14:51:26 UTC
(*** This bug was imported into bugs.kde.org ***)

Package:           kmail
Version:           2.1 (using KDE 2.1.1 )
Severity:          wishlist
Installed from:    Other
Compiler:          gcc 2.95-3
OS:                Linux
OS/Compiler notes: Not Specified

I'd really love the ability to filter out spam by saying-

if the message isn't from someone in my address book ... then do -

(Submitted via bugs.kde.org)
Comment 1 Ingo Klöcker 2002-09-25 18:19:02 UTC
*** Bug 48279 has been marked as a duplicate of this bug. ***
Comment 2 Marc Mutz 2002-10-04 11:17:59 UTC
*** Bug 44764 has been marked as a duplicate of this bug. ***
Comment 3 Caoilte O'Connor 2003-01-23 18:41:30 UTC
I'd just like to add that i would love this feature too, with a few extra features. 
 
-- the ability to group people in my adress book 
-- then the ability to filter based on whether a mail matches one person or a group of 
people in my addressbook. 
 
this would move a lot of the work for the filtering i do at the moment over to the 
addressbook, and seems a lot more intuitive. 
 
 
great work on the filters btw. 
Comment 4 Caoilte O'Connor 2003-01-23 18:43:09 UTC
I'd just like to add that i would love this feature too, with a few extra features.  
  
 the ability to group people in my adress book  
 then the ability to filter based on whether a mail matches one person or a group of  
people in my addressbook.  
  
this would move a lot of the work for the filtering i do at the moment over to the  
addressbook, and seems a lot more intuitive.  
  
  
great work on the filters btw. (this form strips double dashes so i'm resubmitting, sorry) 
Comment 5 Tarax 2003-04-26 13:14:13 UTC
hi, 
 
that would DEFINITIVELY be GREAT features !! 
 
I'd love to be able to create groups of people/mailing lists in my adress book. 
Further it would be wonderfull to be able to create filters based on people/groups 
 
Best regards and THANKS A LOT for the great work yall do 
 
Tarax 
Comment 6 chris319 2003-08-02 23:23:27 UTC
This would be a VERY useful feature.
Comment 7 chris319 2003-08-02 23:24:22 UTC
This would be a VERY useful feature.
Comment 8 Tom Emerson 2003-10-26 02:50:06 UTC
I'm not sure of the history of this as it is noted as "imported into bugs...", it is 2 and a half years old, references a version that is higher than the current [if "2.1" can be believed (?) ] and duplicates one of the items I mentioned in bug 54984 [item 4b: match against address book and/or distro lists] so my guess is that this is a popular item :)
Comment 9 Ingo Klöcker 2004-01-16 17:36:37 UTC
*** Bug 72762 has been marked as a duplicate of this bug. ***
Comment 10 PRLSSREXEQRG 2004-01-16 18:18:33 UTC
i just want to say, that this feature should be included. if it matches with my adressbook, stop filtering and move this mail into a specified folder.
Comment 11 mail 2004-02-26 07:15:46 UTC
As long as this feature is not implemented, I would like to propose a temporary solution that works fine for me. I attached a bash script which I use to pipe through incoming e-mails. It adds an "X-In-Addressbook-Or-Recent"-Tag to the e-mail header with "Yes" if the From-e-mail-address is found in the address book or in the list of recent e-mail receivers located in the kmail configuration file, otherwise with "No". In my kmail configuration, this filter is applied to all incoming e-mails; filters following it can use the tag then. In my case, I let kmail mark the mail as important and then end the filtering, so that mails from known people are not piped through spamassassin.

I'm a relatively new user to Linux, so this script could probably be written more elegant (especially with better from-e-mail-reg-exps), and I don't provide any guarantee that it will work, or that it won't destroy e-mails. So before you try it, make a back up of your data. Anyway, I've been using it for some time and didn't have problems. The X-Tag is always added below the "From"-Header; I don't know if this is conflicting with the specifications of an e-mail header, but it didn't do damage to my e-mail processing in kmail. Based on this position of the header line, the script also supports filtering mails again without writing the X-tag twice.

So here it is. You might need to adjust the paths. Once again, the usual way to use it would be to create a filter piping the mail through this script and then a filter with the following criteria: "X-In-Addressbook-Or-Recent" contains "Yes"

#!/bin/bash

IFS="
"

KABC_VCF_PATH="$HOME/.kde/share/apps/kabc/std.vcf"
KMAILRC_PATH="$HOME/.kde/share/config/kmailrc"
TAGNAME="X-In-Addressbook-Or-Recent:"

fromHeaderFound=0

while read line
do
  echo $line
  if [[ $fromHeaderFound = "0" ]]; then
      if [ ${line:0:6} = "From: " ]; then
	  # Check for e-mail address in < >
	  emailAddress=`expr "$line" : '.*<\(.*\)>.*'`
	  # If not found, check for standalone e-mail address
	  if [ ${#emailAddress} = "0" ]; then
	      emailAddress=`expr "$line" : 'From:\ \(.*\)'`
	  fi
	  # Only add tag if e-mail address could be read
	  if [ ! ${#emailAddress} = "0" ]; then
	      # Check for e-mail address in address book
	      grep -i "$emailAddress" "$KABC_VCF_PATH" > /dev/null
	      if  [ $? = "0" ]; then
		  echo "${TAGNAME} Yes"
	      else
		  # Check for e-mail address in recent list
		  grep -i "$emailAddress" "$KMAILRC_PATH" > /dev/null
		  if  [ $? = "0" ]; then
		      echo "${TAGNAME} Yes"
		  else
		      echo "${TAGNAME} No"
		  fi
	      fi
	  fi
	  fromHeaderFound="1"
	  # Only write next line if it is not an old X-Tag
	  read line
	  if [ ! ${line:0:${#TAGNAME}} = "${TAGNAME}" ]; then
	      echo $line
	  fi
      fi
  fi
done
Comment 12 mail 2004-03-01 03:48:47 UTC
There is a bug in my script (see last comment) that Jochen Puchalla fortunately informed me about. In the "echo $line" commands, I forgot to put $line into quotes, so if there are special characters like * in incoming mails, they will be interpreted by the shell. With *, this makes your home directory appear in mails from other people - not quite a nice experience. So if you're using my script, please correct this by either replacing the two lines with
echo $line
by
echo "$line"
or just copy and paste the new version below. I included spaces instead of tabs this time, so maybe it will even be indented in the comment view ;-).


#!/bin/bash

IFS="
"

KABC_VCF_PATH="$HOME/.kde/share/apps/kabc/std.vcf"
KMAILRC_PATH="$HOME/.kde/share/config/kmailrc"
TAGNAME="X-In-Addressbook-Or-Recent:"

fromHeaderFound=0

while read line
do
  echo "$line"
  if [[ $fromHeaderFound = "0" ]]; then
      if [ ${line:0:6} = "From: " ]; then
          # Check for e-mail address in < >
          emailAddress=`expr "$line" : '.*<\(.*\)>.*'`
          # If not found, check for standalone e-mail address
          if [ ${#emailAddress} = "0" ]; then
              emailAddress=`expr "$line" : 'From:\ \(.*\)'`
          fi
          # Only add tag if e-mail address could be read
          if [ ! ${#emailAddress} = "0" ]; then
              # Check for e-mail address in address book
              grep -i "$emailAddress" "$KABC_VCF_PATH" > /dev/null
              if  [ $? = "0" ]; then
                  echo "${TAGNAME} Yes"
              else
                  # Check for e-mail address in recent list
                  grep -i "$emailAddress" "$KMAILRC_PATH" > /dev/null
                  if  [ $? = "0" ]; then
                      echo "${TAGNAME} Yes"
                  else
                      echo "${TAGNAME} No"
                  fi
              fi
          fi
          fromHeaderFound="1"
          # Only write next line if it is not an old X-Tag
          read line
          if [ ! ${line:0:${#TAGNAME}} = "${TAGNAME}" ]; then
              echo "$line"
          fi
      fi
  fi
done
Comment 13 Ingo Klöcker 2004-03-02 19:19:46 UTC
*** Bug 76561 has been marked as a duplicate of this bug. ***
Comment 14 Martin Köbele 2004-03-26 22:33:35 UTC
two features are in kdepim cvs now and will be in kdepim-3.3:

- filter messages of which the sender is in the addressbook

- filter messages of which the sender is in a certain category (group) of the addressbook.
Comment 15 Ingo Klöcker 2005-03-28 21:00:49 UTC
reset invalid values in Version field to "unspecified"