Bug 358071

Summary: Kmail adds wrong contacts to e-mail when using contact groups
Product: [Applications] kmail2 Reporter: of.bis+kde
Component: generalAssignee: kdepim bugs <kdepim-bugs>
Status: REPORTED ---    
Severity: normal CC: ab.kde, trent2
Priority: NOR    
Version: 5.1   
Target Milestone: ---   
Platform: Arch Linux   
OS: Linux   
Latest Commit: Version Fixed In:
Sentry Crash Report:

Description of.bis+kde 2016-01-16 11:33:14 UTC
Hello.

I have a very annoying bug in the latest kmail version in Manjaro Linux : 
I've set 3 contact groups in the Kaddresbook containing each dozen of contacts,
Names of my groups are "Rando mardi/vendredi", "Rando mardi", "Rando vendredi" (in this order in my contacts list).

When creating a new mail and selecting "Rando mardi/vendredi", the right contacts are added to the recipient list. However when selecting another group e.g "Rando vendredi", the wrong contacts are added to the recipient list ! Actually "Rando mardi/vendredi" are the ones always added, leading to very confusing situations when sending the e-mail !

As I said, "Rando mardi/vendredi" is the first group in my contact list. Could there be a bug because of its #1 position ?

Thank you for considering it. I had to stop using kmail to manage my hiking group because of this (manually adding dozens of recipients to e-mail is a no-go).

Reproducible: Always

Steps to Reproduce:
1. Create new mail
2. Add contact group (not first one) to recipients
3. Send mail

Actual Results:  
Add wrong contacts

Expected Results:  
Add the right contacts

Works ok with my first group in contact list. (Groups created with kaddressbok).
Comment 1 andrew brewster 2017-10-31 09:45:28 UTC
Confirmed, this is the most annoying of bugs that makes using KMail to manage distribution groups near impossible.

You can't send consecutive emails to different groups, as KMail always adds the emails from the first selected group to the second, third and subsequent emails.

Is is something to do with the subject line, or message contents, or both, being the same in each email, and KMail thinks you are trying to resend something that has already been sent, despite trying to send it to a different contact group selected from KAddressBook?

KMail version 5.3.4

rpm -qa | grep kmail
kmail-debuginfo-16.12.3-2.1.mga6
kmail-account-wizard-debuginfo-16.12.3-1.mga6
kmailtransport-16.12.3-1.mga6
kmailtransport-debuginfo-16.12.3-1.mga6
kmail-16.12.3-2.1.mga6
kmail-account-wizard-16.12.3-1.mga6
kmail-handbook-16.12.3-2.1.mga6
lib64kmailprivate5-16.12.3-2.1.mga6
kmailtransport-handbook-16.12.3-1.mga6

rpm -qa | grep kaddress
lib64kaddressbookmergelibprivate5-16.12.3-1.mga6
kaddressbook-16.12.3-1.mga6
lib64kaddressbookimportexportlibprivate5-16.12.3-1.mga6
Comment 2 Robert Spillner 2020-03-20 18:38:39 UTC
This sucks so badly and is a really major show stopper for really anything that has to do with contact groups. How come that in 4 years and God knows how many releases of kmail this has not been fixed!?
Comment 3 Christoph Feck 2020-04-15 19:23:35 UTC
We didn't find a developer or contributor yet who is able to investigate this issue.
Comment 4 Robert Spillner 2020-04-22 10:00:06 UTC
I dug into this bug a little by myself and found out that in order to resolve contact group names into mail addresses kmail does a search via akonadi. When using *spaces* in the contact group names with similar words in both contact group names this search will have multiple results. So if you have two list, say

foo bar
foo crowbar,

and you use "foo crowbar" as recipient the akonadi search query will return "foo bar" and "foo crowbar" since "foo" is in both of them. KMail apparently chooses the first result of the result list, which is "foo bar".

As a workaround, if you rename your contact lists to
foorbar
foocrowbar

this will not happen. Unfortunately, KMail does not allow "_" in the names. I guess that there should be a better input validation and masking of the search word in kmail when quering for a contact group.