+--------------------------------------------------------------------+
| CiviCRM version 5 |
+--------------------------------------------------------------------+
- | Copyright CiviCRM LLC (c) 2004-2018 |
+ | Copyright CiviCRM LLC (c) 2004-2019 |
+--------------------------------------------------------------------+
| This file is a part of CiviCRM. |
| |
/**
*
* @package CRM
- * @copyright CiviCRM LLC (c) 2004-2018
+ * @copyright CiviCRM LLC (c) 2004-2019
*/
require_once 'Mail/mime.php';
$contacts = CRM_Contact_BAO_Contact::getTableName();
$domain_id = CRM_Core_Config::domainID();
$domainValues = civicrm_api3('Domain', 'get', array('sequential' => 1, 'id' => $domain_id));
+ $fromEmail = CRM_Core_BAO_Domain::getNoReplyEmailAddress();
$eq = new CRM_Core_DAO();
$eq->query("SELECT $contacts.display_name as display_name,
// to the forward goes to the sender of the reply
$parsed->setHeader('Reply-To', $replyto instanceof ezcMailAddress ? $replyto : $parsed->from->__toString());
+ // Using the original from address may not be permitted by the mailer.
+ $fromName = empty($parsed->from->name) ? $parsed->from->email : "{$parsed->from->name} ({$parsed->from->email})";
+ $parsed->from = new ezcMailAddress($fromEmail, $fromName);
+
// CRM-17754 Include re-sent headers to indicate that we have forwarded on the email
$domainEmail = $domainValues['values'][0]['from_email'];
$parsed->setHeader('Resent-From', $domainEmail);
$parsed->setHeader('Resent-Date', date('r'));
+ // Rewrite any invalid Return-Path headers.
+ $parsed->setHeader('Return-Path', $fromEmail);
// $h must be an array, so we can't use generateHeaders()'s result,
// but we have to regenerate the headers because we changed To
$h = $parsed->headers->getCaseSensitiveArray();
$b = $parsed->generateBody();
- // strip Return-Path of possible bounding brackets, CRM-4502
- if (!empty($h['Return-Path'])) {
- $h['Return-Path'] = trim($h['Return-Path'], '<>');
- }
-
// FIXME: ugly hack - find the first MIME boundary in
// the body and make the boundary in the header match it
$ct = $h['Content-Type'];
}
}
else {
- if (empty($eq->display_name)) {
- $from = $eq->email;
- }
- else {
- $from = "\"{$eq->display_name}\" <{$eq->email}>";
- }
+ $fromName = empty($eq->display_name) ? $eq->email : "{$eq->display_name} ({$eq->email})";
$message = new Mail_mime("\n");
$headers = array(
'Subject' => "Re: {$mailing->subject}",
'To' => $mailing->replyto_email,
- 'From' => $from,
+ 'From' => "\"$fromName\" <$fromEmail>",
'Reply-To' => empty($replyto) ? $eq->email : $replyto,
'Return-Path' => CRM_Core_BAO_Domain::getNoReplyEmailAddress(),
// CRM-17754 Include re-sent headers to indicate that we have forwarded on the email
$to = empty($replyto) ? $eq->email : $replyto;
- $component = new CRM_Mailing_BAO_Component();
+ $component = new CRM_Mailing_BAO_MailingComponent();
$component->id = $mailing->reply_id;
$component->find(TRUE);