Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Towards CRM-17753 - consolidate code location for do-not-reply@mydomain.com #12270

Merged
merged 1 commit into from
Jun 19, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion CRM/Campaign/BAO/Petition.php
Original file line number Diff line number Diff line change
Expand Up @@ -586,7 +586,7 @@ public static function sendEmail($params, $sendEmailMode) {

$toName = CRM_Contact_BAO_Contact::displayName($params['contactId']);

$replyTo = "do-not-reply@$emailDomain";
$replyTo = CRM_Core_BAO_Domain::getNoReplyEmailAddress();

// set additional general message template params (custom tokens to use in email msg templates)
// tokens then available in msg template as {$petition.title}, etc
Expand Down
8 changes: 8 additions & 0 deletions CRM/Core/BAO/Domain.php
Original file line number Diff line number Diff line change
Expand Up @@ -319,4 +319,12 @@ public static function getDefaultReceiptFrom() {
return array($userName, $userEmail);
}

/**
* Get address to be used for system from addresses when a reply is not expected.
*/
public static function getNoReplyEmailAddress() {
$emailDomain = CRM_Core_BAO_MailSettings::defaultDomain();
return "do-not-reply@$emailDomain";
}

}
8 changes: 3 additions & 5 deletions CRM/Mailing/Event/BAO/Confirm.php
Original file line number Diff line number Diff line change
Expand Up @@ -118,8 +118,6 @@ public static function confirm($contact_id, $subscribe_id, $hash) {

$component->find(TRUE);

$emailDomain = CRM_Core_BAO_MailSettings::defaultDomain();

$html = $component->body_html;

if ($component->body_text) {
Expand All @@ -143,11 +141,11 @@ public static function confirm($contact_id, $subscribe_id, $hash) {
$mailParams = array(
'groupName' => 'Mailing Event ' . $component->component_type,
'subject' => $component->subject,
'from' => "\"$domainEmailName\" <do-not-reply@$emailDomain>",
'from' => "\"$domainEmailName\" <" . CRM_Core_BAO_Domain::getNoReplyEmailAddress() . '>',
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@eileenmcnaughton you need to remove

$emailDomain = CRM_Core_BAO_MailSettings::defaultDomain();

above at line 121

'toEmail' => $email,
'toName' => $display_name,
'replyTo' => "do-not-reply@$emailDomain",
'returnPath' => "do-not-reply@$emailDomain",
'replyTo' => CRM_Core_BAO_Domain::getNoReplyEmailAddress(),
'returnPath' => CRM_Core_BAO_Domain::getNoReplyEmailAddress(),
'html' => $html,
'text' => $text,
);
Expand Down
12 changes: 4 additions & 8 deletions CRM/Mailing/Event/BAO/Reply.php
Original file line number Diff line number Diff line change
Expand Up @@ -173,8 +173,6 @@ public static function send($queue_id, &$mailing, &$bodyTxt, $replyto, &$bodyHTM
}
}
else {
$emailDomain = CRM_Core_BAO_MailSettings::defaultDomain();

if (empty($eq->display_name)) {
$from = $eq->email;
}
Expand All @@ -189,7 +187,7 @@ public static function send($queue_id, &$mailing, &$bodyTxt, $replyto, &$bodyHTM
'To' => $mailing->replyto_email,
'From' => $from,
'Reply-To' => empty($replyto) ? $eq->email : $replyto,
'Return-Path' => "do-not-reply@{$emailDomain}",
'Return-Path' => CRM_Core_BAO_Domain::getNoReplyEmailAddress(),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@eileenmcnaughton you need to remove

$emailDomain = CRM_Core_BAO_MailSettings::defaultDomain();

above at line 176

// CRM-17754 Include re-sent headers to indicate that we have forwarded on the email
'Resent-From' => $domainValues['values'][0]['from_email'],
'Resent-Date' => date('r'),
Expand Down Expand Up @@ -253,14 +251,12 @@ private static function autoRespond(&$mailing, $queue_id, $replyto) {
$domain = CRM_Core_BAO_Domain::getDomain();
list($domainEmailName, $_) = CRM_Core_BAO_Domain::getNameAndEmail();

$emailDomain = CRM_Core_BAO_MailSettings::defaultDomain();

$headers = array(
'Subject' => $component->subject,
'To' => $to,
'From' => "\"$domainEmailName\" <do-not-reply@$emailDomain>",
'Reply-To' => "do-not-reply@$emailDomain",
'Return-Path' => "do-not-reply@$emailDomain",
'From' => "\"$domainEmailName\" <" . CRM_Core_BAO_Domain::getNoReplyEmailAddress() . '>',
'Reply-To' => CRM_Core_BAO_Domain::getNoReplyEmailAddress(),
'Return-Path' => CRM_Core_BAO_Domain::getNoReplyEmailAddress(),
);

// TODO: do we need reply tokens?
Expand Down
8 changes: 3 additions & 5 deletions CRM/Mailing/Event/BAO/Resubscribe.php
Original file line number Diff line number Diff line change
Expand Up @@ -267,14 +267,12 @@ public static function send_resub_response($queue_id, $groups, $is_domain = FALS
$message->setTxtBody($text);
}

$emailDomain = CRM_Core_BAO_MailSettings::defaultDomain();

$headers = array(
'Subject' => $component->subject,
'From' => "\"$domainEmailName\" <do-not-reply@$emailDomain>",
'From' => "\"$domainEmailName\" <" . CRM_Core_BAO_Domain::getNoReplyEmailAddress() . '>',
'To' => $eq->email,
'Reply-To' => "do-not-reply@$emailDomain",
'Return-Path' => "do-not-reply@$emailDomain",
'Reply-To' => CRM_Core_BAO_Domain::getNoReplyEmailAddress(),
'Return-Path' => CRM_Core_BAO_Domain::getNoReplyEmailAddress(),
);
CRM_Mailing_BAO_Mailing::addMessageIdHeader($headers, 'e', $job, $queue_id, $eq->hash);
$b = CRM_Utils_Mail::setMimeParams($message);
Expand Down
2 changes: 1 addition & 1 deletion CRM/Mailing/Event/BAO/Subscribe.php
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@ public function send_confirm_request($email) {
'From' => "\"{$domainEmailName}\" <{$domainEmailAddress}>",
'To' => $email,
'Reply-To' => $confirm,
'Return-Path' => "do-not-reply@$emailDomain",
'Return-Path' => CRM_Core_BAO_Domain::getNoReplyEmailAddress(),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@eileenmcnaughton you need to remove

$emailDomain = CRM_Core_BAO_MailSettings::defaultDomain();

above at line 203

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I updated the others - but this one is still used

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh ok

);

$url = CRM_Utils_System::url('civicrm/mailing/confirm',
Expand Down
6 changes: 3 additions & 3 deletions CRM/Mailing/Event/BAO/Unsubscribe.php
Original file line number Diff line number Diff line change
Expand Up @@ -418,10 +418,10 @@ public static function send_unsub_response($queue_id, $groups, $is_domain = FALS

$headers = array(
'Subject' => $component->subject,
'From' => "\"$domainEmailName\" <do-not-reply@$emailDomain>",
'From' => "\"$domainEmailName\" <" . CRM_Core_BAO_Domain::getNoReplyEmailAddress() . '>',
'To' => $eq->email,
'Reply-To' => "do-not-reply@$emailDomain",
'Return-Path' => "do-not-reply@$emailDomain",
'Reply-To' => CRM_Core_BAO_Domain::getNoReplyEmailAddress(),
'Return-Path' => CRM_Core_BAO_Domain::getNoReplyEmailAddress(),
);
CRM_Mailing_BAO_Mailing::addMessageIdHeader($headers, 'u', $job, $queue_id, $eq->hash);

Expand Down