contact with email might not exist
authordemeritcowboy <demeritcowboy@hotmail.com>
Sun, 12 Sep 2021 13:45:11 +0000 (09:45 -0400)
committerdemeritcowboy <demeritcowboy@hotmail.com>
Sun, 12 Sep 2021 13:45:11 +0000 (09:45 -0400)
CRM/Core/BAO/MessageTemplate.php

index 50ea77fbac8ead0a33e2dc5e8f74159bbf085263..9c485e09480c17bfff7745fab1bf7bc4542e373b 100644 (file)
@@ -375,7 +375,8 @@ class CRM_Core_BAO_MessageTemplate extends CRM_Core_DAO_MessageTemplate {
       // when we likely have the contact id. OTOH people probably barely
       // use preferredMailFormat these days - the good fight against html
       // emails was lost a decade ago...
-      $preferredMailFormat = Email::get(FALSE)->addWhere('email', '=', $params['toEmail'])->addSelect('contact_id.preferred_mail_format')->execute()->first()['contact_id.preferred_mail_format'];
+      $preferredMailFormatArray = Email::get(FALSE)->addWhere('email', '=', $params['toEmail'])->addSelect('contact_id.preferred_mail_format')->execute()->first();
+      $preferredMailFormat = $preferredMailFormatArray['contact_id.preferred_mail_format'] ?? 'Both';
 
       if ($preferredMailFormat === 'HTML') {
         $params['text'] = NULL;