// 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" <toemailaddress>
- $from = CRM_Utils_Mail::mailboxHeader($from);
+ $from = CRM_Utils_Mail::formatFromAddress($from);
$subject = $formValues['subject'];
// CRM-13378: Append CC and BCC information at the end of Activity Details and format cc and bcc fields
CRM_Utils_Hook::alterMailParams($params, 'messageTemplate');
+ // Core#644 - handle contact ID passed as "From".
+ if (isset($params['from'])) {
+ $params['from'] = CRM_Utils_Mail::formatFromAddress($params['from']);
+ }
+
if ((!$params['groupName'] ||
!$params['valueName']
) &&
if (!empty($this->_params['send_receipt'])) {
- $receiptFrom = CRM_Utils_Mail::mailboxHeader($this->_params['from_email_address']);
+ $receiptFrom = $this->_params['from_email_address'];
if (!empty($this->_params['payment_instrument_id'])) {
$paymentInstrument = CRM_Contribute_PseudoConstant::paymentInstrument();
* If it's numeric, look up the display name and email of the corresponding
* contact ID in RFC822 format.
*
- * @param string $header
+ * @param string $from
+ * contact ID or formatted "From address", eg. 12 or "Fred Bloggs" <fred@example.org>
* @return string
* The RFC822-formatted email header (display name + address)
*/
- public static function mailboxHeader($header) {
- if (is_numeric($header)) {
+ public static function formatFromAddress($from) {
+ if (is_numeric($from)) {
$result = civicrm_api3('Email', 'get', [
- 'id' => $header,
+ 'id' => $from,
'return' => ['contact_id.display_name', 'email'],
'sequential' => 1,
])['values'][0];
- $header = '"' . $result['contact_id.display_name'] . '" <' . $result['email'] . '>';
+ $from = '"' . $result['contact_id.display_name'] . '" <' . $result['email'] . '>';
}
- return $header;
+ return $from;
}
}