Details
-
Type: Bug
-
Status: Done/Fixed
-
Priority: Trivial
-
Resolution: Fixed/Completed
-
Affects Version/s: 4.2.7
-
Fix Version/s: 4.3.0
-
Component/s: None
-
Labels:None
Description
The get Test recipients function generates a list of potential recipients for a given email
SELECT e.id, contact_id, email
FROM civicrm_email e
LEFT JOIN civicrm_contact c ON c.id = e.contact_id
WHERE email IN ($emails)
In the database we have there are 3 entries for that email.
ie.
SELECT e.id, contact_id, email, is_opt_out, is_deleted
FROM civicrm_email e
LEFT JOIN civicrm_contact c ON c.id = e.contact_id
WHERE email IN ('lee@my.org');
Returns
id | contact_id | is_opt_out | is_deleted | |
---|---|---|---|---|
235 | 632 | 'lee@my.org | 0 | 0 |
240 | 637 | 'lee@my.org | 1 | 0 |
275 | 672 | 'lee@my.org | 1 | 1 |
The last (highest number of these) is queued - but the runJobs function will not send it out so it never completes here
while (!$isComplete)
{ $isComplete = CRM_Mailing_BAO_Job::runJobs($testParams); }The simplest fix is just to add extra params to the query
$query = "
SELECT e.id, contact_id, email
FROM civicrm_email e
LEFT JOIN civicrm_contact c ON c.id = e.contact_id
WHERE email IN ($emails)
AND is_deleted = 0
AND is_opt_out = 0
";
However, I note that the user was intentially sending a test mail to an opted out user (themself). The does actually seem reasonable to me. If we change the query per above then when they do that they wind up creating a duplicate contact. It may make sense / be easiest to allow a test mail to go to an opted out user (which would involve adding conditionals into CRM_Mailing_BAO_JOB->deliver)