From 97b745fe4c89cc478e3525b94e52edab93fdde62 Mon Sep 17 00:00:00 2001 From: demeritcowboy Date: Sun, 12 Sep 2021 09:45:11 -0400 Subject: [PATCH] contact with email might not exist --- CRM/Core/BAO/MessageTemplate.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/CRM/Core/BAO/MessageTemplate.php b/CRM/Core/BAO/MessageTemplate.php index 50ea77fbac..9c485e0948 100644 --- a/CRM/Core/BAO/MessageTemplate.php +++ b/CRM/Core/BAO/MessageTemplate.php @@ -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; -- 2.25.1