From 0cb9621ac913ed9a45b3ce5f59c5d23fc68ab77f Mon Sep 17 00:00:00 2001 From: Seamus Lee Date: Mon, 17 Sep 2018 07:35:23 +1000 Subject: [PATCH] dev/core#357 Fix issue where user email addresses were keyed on email not id therefore breaking the usage of the signature option on email addresses and ensure that emails still get passed through correctly --- CRM/Contact/Form/Task/EmailCommon.php | 10 ++++++++++ CRM/Core/BAO/Email.php | 2 +- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/CRM/Contact/Form/Task/EmailCommon.php b/CRM/Contact/Form/Task/EmailCommon.php index 889adc25abb2..0e22d6abc94f 100644 --- a/CRM/Contact/Form/Task/EmailCommon.php +++ b/CRM/Contact/Form/Task/EmailCommon.php @@ -396,6 +396,16 @@ public static function submit(&$form, $formValues) { self::saveMessageTemplate($formValues); $from = CRM_Utils_Array::value('from_email_address', $formValues); + // dev/core#357 User Emails are keyed by their id so that the Signature is able to be added + // If we have had a contact email used here the value returned from the line above will be the + // numerical key where as $from for use in the sendEmail in Activity needs to be of format of "To Name" + if (is_numeric($from)) { + $result = civicrm_api3('Email', 'get', [ + 'id' => $from, + 'return' => ['contact_id.display_name', 'email'], + ]); + $from = '"' . $result['values'][$from]['contact_id.display_name'] . '" <' . $result['values'][$from]['email'] . '>'; + } $subject = $formValues['subject']; // CRM-13378: Append CC and BCC information at the end of Activity Details and format cc and bcc fields diff --git a/CRM/Core/BAO/Email.php b/CRM/Core/BAO/Email.php index 7be3aab41f47..b964799cddf9 100644 --- a/CRM/Core/BAO/Email.php +++ b/CRM/Core/BAO/Email.php @@ -333,7 +333,7 @@ public static function getFromEmail() { if (!empty($emailVal['is_primary'])) { $fromEmailHtml .= ' ' . ts('(preferred)'); } - $contactFromEmails[$fromEmail] = $fromEmailHtml; + $contactFromEmails[$emailId] = $fromEmailHtml; } } return CRM_Utils_Array::crmArrayMerge($contactFromEmails, $fromEmailValues);