From 39c2e447198849460a36eac85938896534e1f0f1 Mon Sep 17 00:00:00 2001 From: Harald Bamberger Date: Tue, 28 Jan 2025 10:22:30 +0100 Subject: [PATCH] sancho default sender konfigurierbar machen --- application/config/mail.php | 3 +++ application/helpers/hlp_sancho_helper.php | 24 +++++++++++++---------- config/global.config-default.inc.php | 3 +++ include/sancho.inc.php | 7 +++++-- 4 files changed, 25 insertions(+), 12 deletions(-) diff --git a/application/config/mail.php b/application/config/mail.php index 2ac9a53c3..e7fd53c3a 100644 --- a/application/config/mail.php +++ b/application/config/mail.php @@ -33,6 +33,9 @@ $config['validate'] = false; // If true then the email address will be validated // If enabled will be logged info about emails in Codeigniter error logs $config['enable_debug'] = false; +// default sender +$config['sancho_mail_default_sender'] = SANCHO_MAIL_DEFAULT_SENDER; + // If to use images for custom mails $config['sancho_mail_use_images'] = SANCHO_MAIL_USE_IMAGES; diff --git a/application/helpers/hlp_sancho_helper.php b/application/helpers/hlp_sancho_helper.php index 768447eb2..9a32f5e1a 100644 --- a/application/helpers/hlp_sancho_helper.php +++ b/application/helpers/hlp_sancho_helper.php @@ -51,12 +51,16 @@ function sendSanchoMail( $ci->load->library('email'); $ci->load->library('MailLib'); - $sancho_mail_use_images = $ci->config->item('mail'); + $sancho_mail_config = $ci->config->item('mail'); if ($from == '') { - $from = 'noreply@'.DOMAIN; + $from = ((isset($sancho_mail_config['sancho_mail_default_sender']) + && $sancho_mail_config['sancho_mail_default_sender']) + ? $sancho_mail_config['sancho_mail_default_sender'] + : 'noreply') + . '@' . DOMAIN; } // Embed sancho header and footer image @@ -66,7 +70,7 @@ function sendSanchoMail( $cid_header = ''; $cid_footer = ''; - if (isset($sancho_mail_use_images['sancho_mail_use_images']) && $sancho_mail_use_images['sancho_mail_use_images']) + if (isset($sancho_mail_config['sancho_mail_use_images']) && $sancho_mail_config['sancho_mail_use_images']) { $sanchoHeader_img = ''; $sanchoFooter_img = ''; @@ -76,10 +80,10 @@ function sendSanchoMail( // use provided header image $sanchoHeader_img = $headerImg; } - elseif (isset($sancho_mail_use_images['sancho_mail_header_img']) && $sancho_mail_use_images['sancho_mail_header_img']) + elseif (isset($sancho_mail_config['sancho_mail_header_img']) && $sancho_mail_config['sancho_mail_header_img']) { // use default header image - $sanchoHeader_img = $sancho_mail_use_images['sancho_mail_header_img']; + $sanchoHeader_img = $sancho_mail_config['sancho_mail_header_img']; } if (isset($footerImg) && $footerImg != '') @@ -87,23 +91,23 @@ function sendSanchoMail( // use provided footer image $sanchoFooter_img = $footerImg; } - elseif (isset($sancho_mail_use_images['sancho_mail_footer_img']) && $sancho_mail_use_images['sancho_mail_footer_img']) + elseif (isset($sancho_mail_config['sancho_mail_footer_img']) && $sancho_mail_config['sancho_mail_footer_img']) { // use default footer image - $sanchoFooter_img = $sancho_mail_use_images['sancho_mail_footer_img']; + $sanchoFooter_img = $sancho_mail_config['sancho_mail_footer_img']; } // add image file paths - if (isset($sancho_mail_use_images['sancho_mail_img_path'])) + if (isset($sancho_mail_config['sancho_mail_img_path'])) { if ($sanchoHeader_img != '') { - $sanchoHeader_img = $sancho_mail_use_images['sancho_mail_img_path'].$sanchoHeader_img; + $sanchoHeader_img = $sancho_mail_config['sancho_mail_img_path'].$sanchoHeader_img; } if ($sanchoFooter_img != '') { - $sanchoFooter_img = $sancho_mail_use_images['sancho_mail_img_path'].$sanchoFooter_img; + $sanchoFooter_img = $sancho_mail_config['sancho_mail_img_path'].$sanchoFooter_img; } } diff --git a/config/global.config-default.inc.php b/config/global.config-default.inc.php index bb9ec0069..0d4158b48 100644 --- a/config/global.config-default.inc.php +++ b/config/global.config-default.inc.php @@ -339,6 +339,9 @@ define('DIENSTVERHAELTNIS_SUPPORT', false); // Falls Studstatus (Abmeldung, AbmeldungStg, Unterbrechung, Wiederholung) verwendet wird zeige Hinweistext bei Eingabe einer kommissionellen oder zusaetzlichen kommissionellen Pruefung define('FAS_STUDSTATUS_SHOW_KOMM_PRFG_HINT', false); +// default absender (@DOMAIN wird hinzugefuegt daher ohne angeben) +define('SANCHO_MAIL_DEFAULT_SENDER', 'noreply'); + // header und footer Bilder für eigene Mails verwenden define('SANCHO_MAIL_USE_IMAGES', true); diff --git a/include/sancho.inc.php b/include/sancho.inc.php index e5a9d172f..4da3768b5 100644 --- a/include/sancho.inc.php +++ b/include/sancho.inc.php @@ -24,7 +24,7 @@ require_once(dirname(__FILE__).'/basis_db.class.php'); require_once(dirname(__FILE__).'/mail.class.php'); require_once(dirname(__FILE__).'/vorlage.class.php'); -const DEFAULT_SENDER = 'noreply'; +const FALLBACK_SENDER = 'noreply'; /** * Send single Mail with Sancho Design and Layout. @@ -41,7 +41,10 @@ const DEFAULT_SENDER = 'noreply'; */ function sendSanchoMail($vorlage_kurzbz, $vorlage_data, $to, $subject, $headerImg = '', $footerImg = '', $replyTo = '', $cc = '') { - $from = DEFAULT_SENDER.'@'. DOMAIN; + $from = ((defined('SANCHO_MAIL_DEFAULT_SENDER') && SANCHO_MAIL_DEFAULT_SENDER != '') + ? SANCHO_MAIL_DEFAULT_SENDER + : FALLBACK_SENDER) + . '@' . DOMAIN; $image_path_prefix = dirname(__DIR__).'/'.(defined('SANCHO_MAIL_IMG_PATH') ? SANCHO_MAIL_IMG_PATH : ''); $sanchoHeader_img = '';