From d87aa37a865e6339c3e5bae758f5b5f211bdab37 Mon Sep 17 00:00:00 2001 From: olayiwola-compucorp Date: Mon, 29 May 2023 10:00:21 +0100 Subject: [PATCH] dev/core#4273 - CRM/Mailing - Allow user to configure donotreply from email address --- CRM/Admin/Form/Preferences/Mailing.php | 1 + CRM/Core/BAO/Domain.php | 4 +++- settings/Mailing.setting.php | 16 ++++++++++++++++ templates/CRM/Admin/Form/Preferences/Mailing.hlp | 16 ++++++++++++++++ 4 files changed, 36 insertions(+), 1 deletion(-) create mode 100644 templates/CRM/Admin/Form/Preferences/Mailing.hlp diff --git a/CRM/Admin/Form/Preferences/Mailing.php b/CRM/Admin/Form/Preferences/Mailing.php index 23cc19a9b8..83d0c0e397 100644 --- a/CRM/Admin/Form/Preferences/Mailing.php +++ b/CRM/Admin/Form/Preferences/Mailing.php @@ -22,6 +22,7 @@ class CRM_Admin_Form_Preferences_Mailing extends CRM_Admin_Form_Preferences { protected $_settings = [ 'profile_double_optin' => CRM_Core_BAO_Setting::MAILING_PREFERENCES_NAME, + 'no_reply_email_address' => CRM_Core_BAO_Setting::MAILING_PREFERENCES_NAME, 'profile_add_to_group_double_optin' => CRM_Core_BAO_Setting::MAILING_PREFERENCES_NAME, 'track_civimail_replies' => CRM_Core_BAO_Setting::MAILING_PREFERENCES_NAME, 'civimail_workflow' => CRM_Core_BAO_Setting::MAILING_PREFERENCES_NAME, diff --git a/CRM/Core/BAO/Domain.php b/CRM/Core/BAO/Domain.php index b81d5add43..1462718c86 100644 --- a/CRM/Core/BAO/Domain.php +++ b/CRM/Core/BAO/Domain.php @@ -366,7 +366,9 @@ class CRM_Core_BAO_Domain extends CRM_Core_DAO_Domain { */ public static function getNoReplyEmailAddress() { $emailDomain = CRM_Core_BAO_MailSettings::defaultDomain(); - return "do-not-reply@$emailDomain"; + $noReplyAddress = Civi::settings()->get('no_reply_email_address'); + + return $noReplyAddress ?: "do-not-reply@$emailDomain"; } } diff --git a/settings/Mailing.setting.php b/settings/Mailing.setting.php index 434e78a7ee..d000dc47fd 100644 --- a/settings/Mailing.setting.php +++ b/settings/Mailing.setting.php @@ -33,6 +33,22 @@ return [ 'description' => ts('When CiviMail is enabled, users who "subscribe" to a group from a profile Group(s) checkbox will receive a confirmation email. They must respond (opt-in) before they are added to the group.'), 'help_text' => NULL, ], + 'no_reply_email_address' => [ + 'group_name' => 'Mailing Preferences', + 'group' => 'mailing', + 'name' => 'no_reply_email_address', + 'type' => 'String', + 'html_type' => 'text', + 'default' => NULL, + 'add' => '5.63', + 'title' => ts('No-Reply Address'), + 'validate_callback' => 'CRM_Utils_Rule::email', + 'is_domain' => 1, + 'is_contact' => 0, + 'description' => '', + 'help_text' => NULL, + 'help' => ['id' => 'no_reply_email_address'], + ], 'track_civimail_replies' => [ 'group_name' => 'Mailing Preferences', 'group' => 'mailing', diff --git a/templates/CRM/Admin/Form/Preferences/Mailing.hlp b/templates/CRM/Admin/Form/Preferences/Mailing.hlp new file mode 100644 index 0000000000..8cfe3b810a --- /dev/null +++ b/templates/CRM/Admin/Form/Preferences/Mailing.hlp @@ -0,0 +1,16 @@ +{* + +--------------------------------------------------------------------+ + | Copyright CiviCRM LLC. All rights reserved. | + | | + | This work is published under the GNU AGPLv3 license with some | + | permitted exceptions and without any warranty. For full license | + | and copyright information, see https://civicrm.org/licensing | + +--------------------------------------------------------------------+ +*} +{htxt id="no_reply_email_address-title"} + {ts}Email From Address for no-reply emails.{/ts} +{/htxt} +{htxt id="no_reply_email_address"} +

{ts}Specify an Email From Address to use when the system sends an email but a reply is not expected, for example when a user is sent an email for a double opt-in.{/ts}

+

{ts}Leaving this blank will use the default which will be do-not-reply@default_domain where the default_domain will be the email domain address of your default mailing account also used for bounce handling.{/ts}

+{/htxt} -- 2.25.1