.then(function (deliveryInfos) {
var count = Object.keys(deliveryInfos).length;
if (count === 0) {
- CRM.alert(ts('Could not identify any recipients. Perhaps the group is empty?'));
+ CRM.alert(ts('Could not identify any recipients. Perhaps your test group is empty, or you tried sending to contacts that do not exist and you have no permission to add contacts.'));
}
})
;
$emailId = $emailDetail[$email]['email_id'];
$contactId = $emailDetail[$email]['contact_id'];
}
- if (!$contactId) {
+ if (!$contactId && CRM_Core_Permission::check('add contacts')) {
//create new contact.
$contact = civicrm_api3('Contact', 'create',
[
$contactId = $contact['id'];
$emailId = $contact['values'][$contactId]['api.Email.get']['id'];
}
- civicrm_api3('MailingEventQueue', 'create',
- [
- 'job_id' => $job['id'],
- 'email_id' => $emailId,
- 'contact_id' => $contactId,
- ]
- );
+ if ($emailId && $contactId) {
+ civicrm_api3('MailingEventQueue', 'create',
+ [
+ 'job_id' => $job['id'],
+ 'email_id' => $emailId,
+ 'contact_id' => $contactId,
+ ]
+ );
+ }
}
}