on hold is not respected when two contacts have duplicate email
Overview
If you have group with two contacts that have the same email, a mailing will only send to one of them. Then, if that email bounces with the right classification, one of contacts will have their email put on hold. The next mailing will then ignore that status and send an email to the other contact which has the same email address.
Reproduction steps
Create two contacts that both have a email that doesn't exist and will produce a bounce that civi understands. Create a group with those two contacts. Send one or more mailings, processing the bounce until the contact goes on hold. Then send another mailing.
Current behavior
The mailing goes out to the email address that is on hold.
Expected behavior
The mailing does not go to the on hold email address.
Environment information
- CiviCRM: 5.24.3 with patches that don't affect this issue, available at https://agpl.fsf.org/crm.fsf.org/CURRENT/
Comments
We have many duplicate contacts our database, often 10+ duplicates, thus making bounce processing require 10+ times more bounces, making bounce processing very broken. Civi allows users to create contacts with duplicate emails with the right profile settings, etc, so it should be able to handle the result without breaking bounce processing.
We are using a rule in our email system to detect these emails and avoid sending them, it checks if this count is greater than 0:
select count(*) FROM civicrm_email where email = REPLACEME and on_hold = 1;