$mailingGroup = new CRM_Mailing_DAO_MailingGroup();
$recipientsGroup = $excludeSmartGroupIDs = $includeSmartGroupIDs = $priorMailingIDs = [];
$dao = CRM_Utils_SQL_Select::from('civicrm_mailing_group')
- ->select('GROUP_CONCAT(entity_id SEPARATOR ",") as group_ids, group_type, entity_table')
+ ->select('GROUP_CONCAT(DISTINCT entity_id SEPARATOR ",") as group_ids, group_type, entity_table')
->where('mailing_id = #mailing_id AND entity_table RLIKE "^civicrm_(group.*|mailing)$" ')
->groupBy(['group_type', 'entity_table'])
->param('!groupTableName', CRM_Contact_BAO_Group::getTableName())
}
$this->templates['mailingID'] = $this->id;
+ $this->templates['campaign_id'] = $this->campaign_id;
$this->templates['template_type'] = $this->template_type;
CRM_Utils_Hook::alterMailContent($this->templates);
}
elseif ($contactId === 0) {
//anonymous user
$contact = [];
- CRM_Utils_Hook::tokenValues($contact, $contactId, $job_id);
+ CRM_Utils_Hook::tokenValues($contact, [$contactId], $job_id);
}
else {
$params = [['contact_id', '=', $contactId, 0, 0]];
list($contact) = CRM_Contact_BAO_Query::apiQuery($params);
+ // $contact is an array of [ contactID => contactDetails ]
- //CRM-4524
- $contact = reset($contact);
+ // also call the hook to get contact details
+ CRM_Utils_Hook::tokenValues($contact, [$contactId], $job_id);
+ // Don't send if contact doesn't exist
+ $contact = reset($contact);
if (!$contact || is_a($contact, 'CRM_Core_Error')) {
CRM_Core_Error::debug_log_message(ts('CiviMail will not send email to a non-existent contact: %1',
[1 => $contactId]
$res = NULL;
return $res;
}
-
- // also call the hook to get contact details
- CRM_Utils_Hook::tokenValues($contact, $contactId, $job_id);
}
$pTemplates = $this->getPreparedTemplates();
// correct template IDs here
'override_verp' => TRUE,
'forward_replies' => FALSE,
- 'open_tracking' => TRUE,
- 'url_tracking' => TRUE,
+ 'open_tracking' => Civi::settings()->get('open_tracking_default'),
+ 'url_tracking' => Civi::settings()->get('url_tracking_default'),
'visibility' => 'Public Pages',
'replyto_email' => $domain_email,
'header_id' => CRM_Mailing_PseudoConstant::defaultComponent('header_id', ''),