From 1d4ef06fdb72443cf58a630f4f7d86b36e227993 Mon Sep 17 00:00:00 2001 From: Alex Tselegidis Date: Mon, 4 Mar 2024 10:59:52 +0100 Subject: [PATCH] Add from email/name and reply-to settings in the email.php configuration file (#1465) --- application/config/email.php | 3 +++ application/libraries/Email_messages.php | 30 +++++++++++++++++++++--- 2 files changed, 30 insertions(+), 3 deletions(-) diff --git a/application/config/email.php b/application/config/email.php index 34dd5e0b..0b24bad5 100644 --- a/application/config/email.php +++ b/application/config/email.php @@ -14,5 +14,8 @@ $config['mailtype'] = 'html'; // or 'text' // $config['smtp_pass'] = ''; // $config['smtp_crypto'] = 'ssl'; // or 'tls' // $config['smtp_port'] = 25; +// $config['from_name'] = ''; +// $config['from_address'] = ''; +// $config['reply_to'] = ''; $config['crlf'] = "\r\n"; $config['newline'] = "\r\n"; diff --git a/application/libraries/Email_messages.php b/application/libraries/Email_messages.php index 00f9309f..6a005ee1 100644 --- a/application/libraries/Email_messages.php +++ b/application/libraries/Email_messages.php @@ -106,7 +106,15 @@ class Email_messages true, ); - $this->CI->email->from($settings['company_email'], $settings['company_email']); + $from_name = config('from_name') ?: $settings['company_name']; + $from_address = config('from_address') ?: $settings['company_email']; + $reply_to = config('reply_to') ?: $settings['company_email']; + + $this->CI->email->from($from_address, $from_name); + + if ($reply_to) { + $this->CI->email->reply_to($reply_to); + } $this->CI->email->to($recipient_email); @@ -175,7 +183,15 @@ class Email_messages true, ); - $this->CI->email->from($settings['company_email'], $settings['company_email']); + $from_name = config('from_name') ?: $settings['company_name']; + $from_address = config('from_address') ?: $settings['company_email']; + $reply_to = config('reply_to') ?: $settings['company_email']; + + $this->CI->email->from($from_address, $from_name); + + if ($reply_to) { + $this->CI->email->reply_to($reply_to); + } $this->CI->email->to($recipient_email); @@ -207,7 +223,15 @@ class Email_messages true, ); - $this->CI->email->from($settings['company_email'], $settings['company_email']); + $from_name = config('from_name') ?: $settings['company_name']; + $from_address = config('from_address') ?: $settings['company_email']; + $reply_to = config('reply_to') ?: $settings['company_email']; + + $this->CI->email->from($from_address, $from_name); + + if ($reply_to) { + $this->CI->email->reply_to($reply_to); + } $this->CI->email->to($recipient_email);