Skip to content

Commit

Permalink
Merge branch 'hotfix-41524' into hotfix
Browse files Browse the repository at this point in the history
  • Loading branch information
jimyhuang committed Oct 4, 2024
2 parents 6254d9e + 11357f9 commit 55150a3
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 5 deletions.
2 changes: 1 addition & 1 deletion CRM/Mailing/BAO/Job.php
Original file line number Diff line number Diff line change
Expand Up @@ -608,7 +608,7 @@ public function deliverGroup(&$fields, &$mailing, &$mailer, &$job_date, &$attach
}

// refs #30289, for valid DKIM
if (!strstr($headers['Sender'], $mailer->host) && $mailer->_mailSetting['return_path']) {
if (empty($headers['Sender']) && !empty($mailer->_mailSetting['return_path'])) {
$headers['Sender'] = $mailer->_mailSetting['return_path'];
}

Expand Down
4 changes: 4 additions & 0 deletions CRM/Mailing/BAO/Mailing.php
Original file line number Diff line number Diff line change
Expand Up @@ -1205,6 +1205,10 @@ protected function getVerpAndUrlsAndHeaders($job_id, $event_queue_id, $hash, $em
'Return-Path' => $verp['bounce'],
'Subject' => $this->subject,
);
if (isset($config->enableDMARC) && !empty($config->enableDMARC)) {
// TODO: logic to check current DMARC available options
$headers['Sender'] = $this->from_email;
}
$headers['Reply-To'] = $headers['From'];
self::addMessageIdHeader($headers, 'm', $job_id, $event_queue_id, $hash);

Expand Down
2 changes: 1 addition & 1 deletion CRM/Mailing/BAO/Transactional.php
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ public static function send(&$params, $callback = NULL) {
CRM_Core_Error::ignoreException();

// refs #30289, for valid DKIM
if (!strstr($headers['Sender'], $mailer->host) && $mailer->_mailSetting['return_path']) {
if (empty($headers['Sender']) && !empty($mailer->_mailSetting['return_path'])) {
$headers['Sender'] = $mailer->_mailSetting['return_path'];
}

Expand Down
12 changes: 9 additions & 3 deletions CRM/Utils/Mail.php
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ class CRM_Utils_Mail {
* @return boolean true if a mail was sent, else false
*/
static function send(&$params, $callback = NULL) {
require_once 'CRM/Core/BAO/MailSettings.php';
$config = CRM_Core_Config::singleton();
$returnPath = CRM_Core_BAO_MailSettings::defaultReturnPath();
$from = CRM_Utils_Array::value('from', $params);
if (!$returnPath) {
Expand Down Expand Up @@ -126,7 +126,13 @@ static function send(&$params, $callback = NULL) {
$headers['Content-Transfer-Encoding'] = 'quoted-printable';
$headers['Return-Path'] = CRM_Utils_Array::value('returnPath', $params);
$headers['Reply-To'] = CRM_Utils_Array::value('replyTo', $params, $from);
$headers['Sender'] = CRM_Utils_Array::value('returnPath', $params);

if (isset($config->enableDMARC) && !empty($config->enableDMARC)) {
$headers['Sender'] = self::pluckEmailFromHeader($params['from']);
}
else {
$headers['Sender'] = CRM_Utils_Array::value('returnPath', $params);
}
$headers['Date'] = date('r');
if (CRM_Utils_Array::value('autoSubmitted', $params)) {
$headers['Auto-Submitted'] = "Auto-Generated";
Expand Down Expand Up @@ -204,7 +210,7 @@ static function send(&$params, $callback = NULL) {
CRM_Core_Error::ignoreException();
if (is_object($mailer)) {
// refs #30289, for valid DKIM
if (!strstr($headers['Sender'], $mailer->host) && $mailer->_mailSetting['return_path']) {
if (empty($headers['Sender']) && !empty($mailer->_mailSetting['return_path'])) {
$headers['Sender'] = $mailer->_mailSetting['return_path'];
$headers['Return-Path'] = $mailer->_mailSetting['return_path'];
}
Expand Down

0 comments on commit 55150a3

Please sign in to comment.