// if any email is marked on_hold =1 or contact is deceased after mailing is submitted
// then it should be get skipped while preparing event_queue
// event_queue list is prepared when mailing job gets started.
- $additionalJoin = " INNER JOIN civicrm_email e ON (r.email_id = e.id AND e.on_hold = 0 AND e.is_primary = 1)
+ $additionalJoin = " INNER JOIN civicrm_email e ON (r.email_id = e.id AND e.on_hold = 0)
INNER JOIN civicrm_contact c on (c.id = r.contact_id AND c.is_deceased <> 1 AND c.do_not_email = 0 AND c.is_opt_out = 0)
";
}
}
+ /**
+ * Test that "multiple bulk email recipients" setting is respected.
+ */
+ public function testMultipleBulkRecipients() {
+ Civi::settings()->add([
+ 'civimail_multiple_bulk_emails' => 1,
+ ]);
+ $contactID = $this->individualCreate(['first_name' => 'test recipient']);
+ $email1 = $this->callAPISuccess('email', 'create', [
+ 'contact_id' => $contactID,
+ 'email' => 'mail1@example.org',
+ 'is_bulkmail' => 1,
+ ]);
+ $email2 = $this->callAPISuccess('email', 'create', [
+ 'contact_id' => $contactID,
+ 'email' => 'mail2@example.org',
+ 'is_bulkmail' => 1,
+ ]);
+ $this->callAPISuccess('group_contact', 'create', [
+ 'contact_id' => $contactID,
+ 'group_id' => $this->_groupID,
+ 'status' => 'Added',
+ ]);
+ $mailing = $this->callAPISuccess('mailing', 'create', $this->_params);
+ $this->assertEquals(2, $this->callAPISuccess('MailingRecipients', 'get', ['mailing_id' => $mailing['id']])['count']);
+ $this->callAPISuccess('job', 'process_mailing', []);
+ $this->_mut->assertRecipients([['mail1@example.org'], ['mail2@example.org']]);
+ // Don't leave data lying around for other tests to screw up on.
+ $this->callAPISuccess('Email', 'delete', ['id' => $email1['id']]);
+ $this->callAPISuccess('Email', 'delete', ['id' => $email2['id']]);
+ }
+
/**
* Test pause and resume on Mailing.
*/