- 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,
+ ]
+ );
+ }