From 6dba5ca0fa7dce442b689647ed2e98e1345f2ecc 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 | 6 ++++- settings/Mailing.setting.php | 22 +++++++++++++++++++ .../CRM/Admin/Form/Preferences/Mailing.hlp | 17 ++++++++++++++ 4 files changed, 45 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 23cc19a9b8cb..83d0c0e3970f 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 b81d5add43bb..b72290d2dd95 100644 --- a/CRM/Core/BAO/Domain.php +++ b/CRM/Core/BAO/Domain.php @@ -366,7 +366,11 @@ public static function getDefaultReceiptFrom() { */ public static function getNoReplyEmailAddress() { $emailDomain = CRM_Core_BAO_MailSettings::defaultDomain(); - return "do-not-reply@$emailDomain"; + $noReplyAddress = \Civi\Api4\Setting::get(FALSE) + ->addSelect('no_reply_email_address:label') + ->execute()->first(); + + return $noReplyAddress['value'] ?: "do-not-reply@$emailDomain"; } } diff --git a/settings/Mailing.setting.php b/settings/Mailing.setting.php index 434e78a7ee38..46512ee1ebf1 100644 --- a/settings/Mailing.setting.php +++ b/settings/Mailing.setting.php @@ -33,6 +33,28 @@ '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', + 'quick_form_type' => 'Select', + 'html_type' => 'select', + 'html_attributes' => [ + 'class' => 'crm-select2', + ], + 'default' => NULL, + 'pseudoconstant' => [ + 'optionGroupName' => 'from_email_address', + ], + 'add' => '5.63', + 'title' => ts('Email From Address to use where a reply is not expected'), + '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 000000000000..c180ed99aa05 --- /dev/null +++ b/templates/CRM/Admin/Form/Preferences/Mailing.hlp @@ -0,0 +1,17 @@ +{* + +--------------------------------------------------------------------+ + | 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}

+

{ts}Edit From Email Addresses{/ts}

+{/htxt}