X-Git-Url: https://vcs.fsf.org/?a=blobdiff_plain;f=api%2Fv3%2FMailing.php;h=756cf75ab823b438455be3ec686c011aa7969b62;hb=86d6364d0921ecffc1039fbf4255009e98ae9e83;hp=011a19f149ef88d2570850dbc7f3166d4ec59ce7;hpb=5bbbc7fe1543094478ecc72fc60389db843371d7;p=civicrm-core.git diff --git a/api/v3/Mailing.php b/api/v3/Mailing.php index 011a19f149..756cf75ab8 100644 --- a/api/v3/Mailing.php +++ b/api/v3/Mailing.php @@ -657,7 +657,7 @@ function civicrm_api3_mailing_send_test($params) { $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', [ @@ -669,13 +669,15 @@ function civicrm_api3_mailing_send_test($params) { $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, + ] + ); + } } }