From efcef48f89495172093bccee2a4940b967022f58 Mon Sep 17 00:00:00 2001 From: Cris Date: Mon, 9 May 2022 11:14:01 +0200 Subject: [PATCH 01/11] Changed Sanchomail 'From' to noreply --- application/helpers/hlp_sancho_helper.php | 2 +- include/sancho.inc.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/application/helpers/hlp_sancho_helper.php b/application/helpers/hlp_sancho_helper.php index d599e40bc..e57802432 100644 --- a/application/helpers/hlp_sancho_helper.php +++ b/application/helpers/hlp_sancho_helper.php @@ -49,7 +49,7 @@ function sendSanchoMail($vorlage_kurzbz, $vorlage_data, $to, $subject, $headerIm if ($from == '') { - $from = 'sancho@'.DOMAIN; + $from = 'noreply@'.DOMAIN; } // Embed sancho header and footer image diff --git a/include/sancho.inc.php b/include/sancho.inc.php index 5fc6fcdab..0d5c8e8a4 100644 --- a/include/sancho.inc.php +++ b/include/sancho.inc.php @@ -40,7 +40,7 @@ const DEFAULT_SANCHO_FOOTER_IMG = 'sancho_footer_DEFAULT.jpg'; */ function sendSanchoMail($vorlage_kurzbz, $vorlage_data, $to, $subject, $headerImg = DEFAULT_SANCHO_HEADER_IMG, $footerImg = DEFAULT_SANCHO_FOOTER_IMG, $replyTo = '', $cc = '') { - $from = 'sancho@'. DOMAIN; + $from = 'noreply@'. DOMAIN; $sanchoHeader_img = dirname(__FILE__). '/../skin/images/sancho/'. $headerImg; $sanchoFooter_img = dirname(__FILE__). '/../skin/images/sancho/'. $footerImg; From c39174980cd78bb6e44a273696dc886c141ac14e Mon Sep 17 00:00:00 2001 From: Cris Date: Mon, 9 May 2022 15:34:22 +0200 Subject: [PATCH 02/11] Fixed function _getSTGLMailAddress to return same array structure Different structure was causing errors in handling. --- application/controllers/jobs/AnrechnungJob.php | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/application/controllers/jobs/AnrechnungJob.php b/application/controllers/jobs/AnrechnungJob.php index f32a8268a..4c341af50 100644 --- a/application/controllers/jobs/AnrechnungJob.php +++ b/application/controllers/jobs/AnrechnungJob.php @@ -358,8 +358,6 @@ html; 'vorname' => $stgl->vorname ); } - - return $stglMailAdress_arr; } // If not available, get assistance mail address else @@ -368,12 +366,13 @@ html; if (hasData($result)) { - return array( - $result->retval[0]->email, - '' + $stglMailAdress_arr[]= array( + 'to' => $result->retval[0]->email, + 'vorname' => '' ); } } + return $stglMailAdress_arr; } // Build HTML table with yesterdays new Anrechnungen of the given STG From 06179ee7148e6c4830c60be654221486d7987c94 Mon Sep 17 00:00:00 2001 From: Paolo Date: Thu, 23 Mar 2023 14:38:42 +0100 Subject: [PATCH 03/11] Code quality check fixes --- application/helpers/hlp_sancho_helper.php | 25 +++++++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-) diff --git a/application/helpers/hlp_sancho_helper.php b/application/helpers/hlp_sancho_helper.php index e57802432..f101ce89d 100644 --- a/application/helpers/hlp_sancho_helper.php +++ b/application/helpers/hlp_sancho_helper.php @@ -38,7 +38,17 @@ const DEFAULT_SANCHO_FOOTER_IMG = 'sancho_footer_DEFAULT.jpg'; * @param string $bcc Sets BCC of mail. * @return void */ -function sendSanchoMail($vorlage_kurzbz, $vorlage_data, $to, $subject, $headerImg = DEFAULT_SANCHO_HEADER_IMG, $footerImg = DEFAULT_SANCHO_FOOTER_IMG, $from = null, $cc = null, $bcc = null) +function sendSanchoMail( + $vorlage_kurzbz, + $vorlage_data, + $to, + $subject, + $headerImg = DEFAULT_SANCHO_HEADER_IMG, + $footerImg = DEFAULT_SANCHO_FOOTER_IMG, + $from = null, + $cc = null, + $bcc = null +) { $ci =& get_instance(); $ci->load->library('email'); @@ -74,7 +84,18 @@ function sendSanchoMail($vorlage_kurzbz, $vorlage_data, $to, $subject, $headerIm $body = _parseMailContent('Sancho_Mail_Template', $layout); // Send mail - return $ci->maillib->send($from, $to, $subject, $body, $alias = '', $cc, $bcc, $altMessage = '', $bulk = true, $autogenerated = true); + return $ci->maillib->send( + $from, + $to, + $subject, + $body, + '', // alias + $cc, + $bcc, + '', // altMessage + true, // bulk + true // autogenerated + ); } /** From 6b169d4183a77399fd63f8f13268df1b3844fe8b Mon Sep 17 00:00:00 2001 From: Alexei Karpenko Date: Sat, 11 Jan 2025 15:43:30 +0100 Subject: [PATCH 04/11] sancho mail: configuration of header/footer and sender is possible --- cis/private/mailtest.php | 24 +++++++ config/global.config-default.inc.php | 9 +++ include/sancho.inc.php | 95 ++++++++++++++++++++++------ 3 files changed, 110 insertions(+), 18 deletions(-) create mode 100644 cis/private/mailtest.php diff --git a/cis/private/mailtest.php b/cis/private/mailtest.php new file mode 100644 index 000000000..e2de76d3b --- /dev/null +++ b/cis/private/mailtest.php @@ -0,0 +1,24 @@ + diff --git a/include/sancho.inc.php b/include/sancho.inc.php index 0d5c8e8a4..c0271196f 100644 --- a/include/sancho.inc.php +++ b/include/sancho.inc.php @@ -18,12 +18,16 @@ * * Authors: Cristina Hainberger */ + +require_once(dirname(__FILE__).'/../config/global.config.inc.php'); require_once(dirname(__FILE__).'/basis_db.class.php'); require_once(dirname(__FILE__).'/mail.class.php'); require_once(dirname(__FILE__).'/vorlage.class.php'); -const DEFAULT_SANCHO_HEADER_IMG = 'sancho_header_DEFAULT.jpg'; -const DEFAULT_SANCHO_FOOTER_IMG = 'sancho_footer_DEFAULT.jpg'; +// TODO: keep this so that an image is used in any case? +//const DEFAULT_SANCHO_HEADER_IMG = 'sancho_header_DEFAULT.jpg'; +//const DEFAULT_SANCHO_FOOTER_IMG = 'sancho_footer_DEFAULT.jpg'; +const DEFAULT_SENDER = 'noreply'; /** * Send single Mail with Sancho Design and Layout. @@ -32,22 +36,75 @@ const DEFAULT_SANCHO_FOOTER_IMG = 'sancho_footer_DEFAULT.jpg'; * to be replaced in the content template. * @param string $to Email-adress. * @param string $subject Subject of mail. - * @param string $headerImg Filename of the specific Sancho header image. - * @param string $footerImg + * @param string $headerImg Filename of the specific Sancho header image, false if no header image + * @param string $footerImg - false if no footer image * @param string $replyTo default Email-adress for reply. * @param string | array $cc * @return boolean True, if succeeded. */ -function sendSanchoMail($vorlage_kurzbz, $vorlage_data, $to, $subject, $headerImg = DEFAULT_SANCHO_HEADER_IMG, $footerImg = DEFAULT_SANCHO_FOOTER_IMG, $replyTo = '', $cc = '') -{ - $from = 'noreply@'. DOMAIN; - $sanchoHeader_img = dirname(__FILE__). '/../skin/images/sancho/'. $headerImg; - $sanchoFooter_img = dirname(__FILE__). '/../skin/images/sancho/'. $footerImg; +function sendSanchoMail($vorlage_kurzbz, $vorlage_data, $to, $subject, $headerImg = '', $footerImg = '', $replyTo = '', $cc = '') +{ + $from = defined('CUSTOM_MAIl_SENDER') && CUSTOM_MAIl_SENDER != '' ? CUSTOM_MAIl_SENDER : DEFAULT_SENDER; + $from = $from.'@'. DOMAIN; + + $image_path_prefix = dirname(__FILE__). '/../skin/images/sancho/'; + + //$sanchoHeader_img = dirname(__FILE__). '/../skin/images/sancho/'. self::DEFAULT_SANCHO_HEADER_IMG; + // hide header by default + $sanchoHeader_img = false; + $header_visibility = 'display:none'; + + if ($headerImg !== false) + { + if (isset($headerImg) && $headerImg != '') + { + // use provided header image + $sanchoHeader_img = $headerImg; + } + elseif (defined('CUSTOM_MAIl_HEADER_IMG') && CUSTOM_MAIl_HEADER_IMG != '') + { + // use default header image + $sanchoHeader_img = CUSTOM_MAIl_HEADER_IMG; + } + + if ($sanchoHeader_img !== false) + { + // set full image path and visibility + $sanchoHeader_img = $image_path_prefix.$sanchoHeader_img; + $header_visibility = ''; + } + } + + //$sanchoFooter_img = dirname(__FILE__). '/../skin/images/sancho/'. self::DEFAULT_SANCHO_FOOTER_IMG; + // hide footer by default + $sanchoFooter_img = false; + $footer_visibility = 'display:none'; + + if ($footerImg !== false) + { + if (isset($footerImg) && $footerImg != '') + { + // use provided footer image + $sanchoFooter_img = $footerImg; + } + elseif (defined('CUSTOM_MAIl_FOOTER_IMG') && CUSTOM_MAIl_FOOTER_IMG != '') + { + // use default footer image + $sanchoFooter_img = CUSTOM_MAIl_FOOTER_IMG; + } + + if ($sanchoFooter_img !== false) + { + // set full image path and visibility + $sanchoFooter_img = $image_path_prefix.$sanchoFooter_img; + $footer_visibility = ''; + } + } // Set unique content id for embedding header and footer image $cid_header = uniqid(); $cid_footer = uniqid(); - + // Set specific mail content into specific content template $content = parseMailContent($vorlage_kurzbz, $vorlage_data); @@ -55,7 +112,9 @@ function sendSanchoMail($vorlage_kurzbz, $vorlage_data, $to, $subject, $headerIm $layout = array( 'CID_header' => $cid_header, 'CID_footer' => $cid_footer, - 'content' => $content + 'content' => $content, + 'header_visibility' => $header_visibility, + 'footer_visibility' => $footer_visibility ); // Set the data array into overall sancho mail template @@ -63,22 +122,22 @@ function sendSanchoMail($vorlage_kurzbz, $vorlage_data, $to, $subject, $headerIm // Send mail $mail = new Mail($to, $from, $subject, $body); - - // * embed the images - $mail->addEmbeddedImage($sanchoHeader_img, 'image/jpg', '', $cid_header); - $mail->addEmbeddedImage($sanchoFooter_img, 'image/jpg', '', $cid_footer); + + // * embed the images if needed + if ($sanchoHeader_img !== false) $mail->addEmbeddedImage($sanchoHeader_img, 'image/jpg', '', $cid_header); + if ($sanchoFooter_img !== false) $mail->addEmbeddedImage($sanchoFooter_img, 'image/jpg', '', $cid_footer); // * Set reply-to if (isset($replyTo) && $replyTo != '') $mail->setReplyTo($replyTo); - + // * Set cc if (isset($cc) && $cc != '') $mail->setCCRecievers($cc); // * embed the html content $mail->setHTMLContent($body); - + return $mail->send(); } @@ -95,7 +154,7 @@ function parseMailContent($vorlage_kurzbz, $vorlage_data) { $vorlage = new Vorlage(); $vorlage->getAktuelleVorlage('etw', $vorlage_kurzbz); - + // If the text and the subject of the template are not empty if (!empty($vorlage->text)) { From 6c858141fdfb980c2a86558d36f795dca1d6f141 Mon Sep 17 00:00:00 2001 From: Alexei Karpenko Date: Mon, 13 Jan 2025 16:22:45 +0100 Subject: [PATCH 05/11] deleted mailtest file --- cis/private/mailtest.php | 24 ------------------------ 1 file changed, 24 deletions(-) delete mode 100644 cis/private/mailtest.php diff --git a/cis/private/mailtest.php b/cis/private/mailtest.php deleted file mode 100644 index e2de76d3b..000000000 --- a/cis/private/mailtest.php +++ /dev/null @@ -1,24 +0,0 @@ - Date: Tue, 14 Jan 2025 17:24:40 +0100 Subject: [PATCH 06/11] sancho mails: added CUSTOM_MAIL_USE_IMAGES config for sending mails without header/footer, removed option to hide mail html --- config/global.config-default.inc.php | 12 +++--- include/sancho.inc.php | 56 ++++++++++------------------ 2 files changed, 25 insertions(+), 43 deletions(-) diff --git a/config/global.config-default.inc.php b/config/global.config-default.inc.php index d62df361d..82efcb11e 100644 --- a/config/global.config-default.inc.php +++ b/config/global.config-default.inc.php @@ -314,12 +314,12 @@ define ('ZAHLUNGSBESTAETIGUNG_ANZEIGEN_FUER_LEHRGAENGE', true); // Gibt an, ob im CIS die Zahlungsreferenz angezeigt wird define ('ZAHLUNGSBESTAETIGUNG_ZAHLUNGSREFERENZ_ANZEIGEN', false); -// sender for custom mails -define('CUSTOM_MAIl_SENDER', 'noreply'); +// header und footer Bilder für eigene Mails verwenden +define('CUSTOM_MAIL_USE_IMAGES', true); -// header image for custom mails -define('CUSTOM_MAIl_HEADER_IMG', 'sancho_header_DEFAULT.jpg'); +// header Bild für eigene Mails +define('CUSTOM_MAIL_HEADER_IMG', 'sancho_header_DEFAULT.jpg'); -// footer image for custom mails -define('CUSTOM_MAIl_FOOTER_IMG', 'sancho_footer_DEFAULT.jpg'); +// footer image for eigene Mails +define('CUSTOM_MAIL_FOOTER_IMG', 'sancho_footer_DEFAULT.jpg'); ?> diff --git a/include/sancho.inc.php b/include/sancho.inc.php index c0271196f..120315eac 100644 --- a/include/sancho.inc.php +++ b/include/sancho.inc.php @@ -24,9 +24,6 @@ require_once(dirname(__FILE__).'/basis_db.class.php'); require_once(dirname(__FILE__).'/mail.class.php'); require_once(dirname(__FILE__).'/vorlage.class.php'); -// TODO: keep this so that an image is used in any case? -//const DEFAULT_SANCHO_HEADER_IMG = 'sancho_header_DEFAULT.jpg'; -//const DEFAULT_SANCHO_FOOTER_IMG = 'sancho_footer_DEFAULT.jpg'; const DEFAULT_SENDER = 'noreply'; /** @@ -44,60 +41,47 @@ const DEFAULT_SENDER = 'noreply'; */ function sendSanchoMail($vorlage_kurzbz, $vorlage_data, $to, $subject, $headerImg = '', $footerImg = '', $replyTo = '', $cc = '') { - $from = defined('CUSTOM_MAIl_SENDER') && CUSTOM_MAIl_SENDER != '' ? CUSTOM_MAIl_SENDER : DEFAULT_SENDER; - $from = $from.'@'. DOMAIN; + $from = DEFAULT_SENDER.'@'. DOMAIN; - $image_path_prefix = dirname(__FILE__). '/../skin/images/sancho/'; + $header_image_path_prefix = dirname(__FILE__). '/../skin/images/sancho/'; + $footer_image_path_prefix = dirname(__FILE__). '/../skin/images/sancho/'; + $sanchoHeader_img = ''; + $sanchoFooter_img = ''; - //$sanchoHeader_img = dirname(__FILE__). '/../skin/images/sancho/'. self::DEFAULT_SANCHO_HEADER_IMG; - // hide header by default - $sanchoHeader_img = false; - $header_visibility = 'display:none'; - - if ($headerImg !== false) + if (!defined('CUSTOM_MAIL_USE_IMAGES') || CUSTOM_MAIL_USE_IMAGES) { if (isset($headerImg) && $headerImg != '') { // use provided header image $sanchoHeader_img = $headerImg; } - elseif (defined('CUSTOM_MAIl_HEADER_IMG') && CUSTOM_MAIl_HEADER_IMG != '') + elseif (defined('CUSTOM_MAIL_HEADER_IMG') && CUSTOM_MAIL_HEADER_IMG != '') { // use default header image - $sanchoHeader_img = CUSTOM_MAIl_HEADER_IMG; + $sanchoHeader_img = CUSTOM_MAIL_HEADER_IMG; } - if ($sanchoHeader_img !== false) + if ($sanchoHeader_img != '') { - // set full image path and visibility - $sanchoHeader_img = $image_path_prefix.$sanchoHeader_img; - $header_visibility = ''; + // set full image path + $sanchoHeader_img = $header_image_path_prefix.$sanchoHeader_img; } - } - //$sanchoFooter_img = dirname(__FILE__). '/../skin/images/sancho/'. self::DEFAULT_SANCHO_FOOTER_IMG; - // hide footer by default - $sanchoFooter_img = false; - $footer_visibility = 'display:none'; - - if ($footerImg !== false) - { if (isset($footerImg) && $footerImg != '') { // use provided footer image $sanchoFooter_img = $footerImg; } - elseif (defined('CUSTOM_MAIl_FOOTER_IMG') && CUSTOM_MAIl_FOOTER_IMG != '') + elseif (defined('CUSTOM_MAIL_FOOTER_IMG') && CUSTOM_MAIL_FOOTER_IMG != '') { // use default footer image - $sanchoFooter_img = CUSTOM_MAIl_FOOTER_IMG; + $sanchoFooter_img = CUSTOM_MAIL_FOOTER_IMG; } - if ($sanchoFooter_img !== false) + if ($sanchoFooter_img !== '') { - // set full image path and visibility - $sanchoFooter_img = $image_path_prefix.$sanchoFooter_img; - $footer_visibility = ''; + // set full image path + $sanchoFooter_img = $footer_image_path_prefix.$sanchoFooter_img; } } @@ -112,9 +96,7 @@ function sendSanchoMail($vorlage_kurzbz, $vorlage_data, $to, $subject, $headerIm $layout = array( 'CID_header' => $cid_header, 'CID_footer' => $cid_footer, - 'content' => $content, - 'header_visibility' => $header_visibility, - 'footer_visibility' => $footer_visibility + 'content' => $content ); // Set the data array into overall sancho mail template @@ -124,8 +106,8 @@ function sendSanchoMail($vorlage_kurzbz, $vorlage_data, $to, $subject, $headerIm $mail = new Mail($to, $from, $subject, $body); // * embed the images if needed - if ($sanchoHeader_img !== false) $mail->addEmbeddedImage($sanchoHeader_img, 'image/jpg', '', $cid_header); - if ($sanchoFooter_img !== false) $mail->addEmbeddedImage($sanchoFooter_img, 'image/jpg', '', $cid_footer); + if ($sanchoHeader_img != '') $mail->addEmbeddedImage($sanchoHeader_img, 'image/jpg', '', $cid_header); + if ($sanchoFooter_img != '') $mail->addEmbeddedImage($sanchoFooter_img, 'image/jpg', '', $cid_footer); // * Set reply-to if (isset($replyTo) && $replyTo != '') From ece4f4a8b520261b5a7647838c5574e6dbcfaac5 Mon Sep 17 00:00:00 2001 From: Alexei Karpenko Date: Wed, 15 Jan 2025 16:52:11 +0100 Subject: [PATCH 07/11] sancho mails: enabled removing of header/footer and custom header/footer images in code igniter code, legacy code: global ids for images are created only if config is set --- application/config/mail.php | 9 ++++ application/helpers/hlp_sancho_helper.php | 51 ++++++++++++++++++----- include/sancho.inc.php | 10 +++-- 3 files changed, 55 insertions(+), 15 deletions(-) diff --git a/application/config/mail.php b/application/config/mail.php index 9d577720d..c89400ed1 100644 --- a/application/config/mail.php +++ b/application/config/mail.php @@ -32,3 +32,12 @@ $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; + +// If to use images for custom mails +$config['custom_mail_use_images'] = CUSTOM_MAIL_USE_IMAGES; + +// header image for custom mails +$config['custom_mail_header_img'] = CUSTOM_MAIL_HEADER_IMG; + +// footer image for custom mails +$config['custom_mail_footer_img'] = CUSTOM_MAIL_FOOTER_IMG; diff --git a/application/helpers/hlp_sancho_helper.php b/application/helpers/hlp_sancho_helper.php index f101ce89d..d11b6522e 100644 --- a/application/helpers/hlp_sancho_helper.php +++ b/application/helpers/hlp_sancho_helper.php @@ -23,9 +23,6 @@ if (! defined('BASEPATH')) exit('No direct script access allowed'); // Functions needed in the view FHC-Header // ------------------------------------------------------------------------ -const DEFAULT_SANCHO_HEADER_IMG = 'sancho_header_DEFAULT.jpg'; -const DEFAULT_SANCHO_FOOTER_IMG = 'sancho_footer_DEFAULT.jpg'; - /** * Send single Mail with Sancho Design and Layout. * @param string $vorlage_kurzbz Name of the template for specific mail content. @@ -43,8 +40,8 @@ function sendSanchoMail( $vorlage_data, $to, $subject, - $headerImg = DEFAULT_SANCHO_HEADER_IMG, - $footerImg = DEFAULT_SANCHO_FOOTER_IMG, + $headerImg = '', + $footerImg = '', $from = null, $cc = null, $bcc = null @@ -54,8 +51,8 @@ function sendSanchoMail( $ci->load->library('email'); $ci->load->library('MailLib'); - $sanchoHeader_img = 'skin/images/sancho/'. $headerImg; - $sanchoFooter_img = 'skin/images/sancho/'. $footerImg; + $custom_mail_use_images = $ci->config->item('mail'); + if ($from == '') { @@ -65,10 +62,42 @@ function sendSanchoMail( // Embed sancho header and footer image // reset important to ensure embedding of images when called in a loop $ci->email->clear(true); // clear vars and attachments - $ci->email->attach($sanchoHeader_img); - $ci->email->attach($sanchoFooter_img); - $cid_header = $ci->email->attachment_cid($sanchoHeader_img); // sets unique content id for embedding - $cid_footer = $ci->email->attachment_cid($sanchoFooter_img); // sets unique content id for embedding + + $cid_header = ''; + $cid_footer = ''; + + if (isset($custom_mail_use_images['custom_mail_use_images']) && $custom_mail_use_images['custom_mail_use_images']) + { + $sanchoHeader_img = ''; + $sanchoFooter_img = ''; + + if (isset($headerImg) && $headerImg != '') + { + // use provided header image + $sanchoHeader_img = $headerImg; + } + elseif (isset($custom_mail_use_images['custom_mail_header_img']) && $custom_mail_use_images['custom_mail_header_img']) + { + // use default header image + $sanchoHeader_img = 'skin/images/sancho/'. $custom_mail_use_images['custom_mail_header_img']; + } + + if (isset($footerImg) && $footerImg != '') + { + // use provided footer image + $sanchoFooter_img = $footerImg; + } + elseif (isset($custom_mail_use_images['custom_mail_footer_img']) && $custom_mail_use_images['custom_mail_footer_img']) + { + // use default footer image + $sanchoFooter_img = 'skin/images/sancho/'. $custom_mail_use_images['custom_mail_footer_img']; + } + + $ci->email->attach($sanchoHeader_img); + $ci->email->attach($sanchoFooter_img); + $cid_header = $ci->email->attachment_cid($sanchoHeader_img); // sets unique content id for embedding + $cid_footer = $ci->email->attachment_cid($sanchoFooter_img); // sets unique content id for embedding + } // Set specific mail content into specific content template $content = _parseMailContent($vorlage_kurzbz, $vorlage_data); diff --git a/include/sancho.inc.php b/include/sancho.inc.php index 120315eac..4fdf467e0 100644 --- a/include/sancho.inc.php +++ b/include/sancho.inc.php @@ -47,6 +47,8 @@ function sendSanchoMail($vorlage_kurzbz, $vorlage_data, $to, $subject, $headerIm $footer_image_path_prefix = dirname(__FILE__). '/../skin/images/sancho/'; $sanchoHeader_img = ''; $sanchoFooter_img = ''; + $cid_header = ''; + $cid_footer = ''; if (!defined('CUSTOM_MAIL_USE_IMAGES') || CUSTOM_MAIL_USE_IMAGES) { @@ -83,11 +85,11 @@ function sendSanchoMail($vorlage_kurzbz, $vorlage_data, $to, $subject, $headerIm // set full image path $sanchoFooter_img = $footer_image_path_prefix.$sanchoFooter_img; } - } - // Set unique content id for embedding header and footer image - $cid_header = uniqid(); - $cid_footer = uniqid(); + // Set unique content id for embedding header and footer image + $cid_header = uniqid(); + $cid_footer = uniqid(); + } // Set specific mail content into specific content template $content = parseMailContent($vorlage_kurzbz, $vorlage_data); From 899c36c52c0bef1d283a6a4ecfc2bb1cbd57dada Mon Sep 17 00:00:00 2001 From: Harald Bamberger Date: Mon, 20 Jan 2025 15:10:52 +0100 Subject: [PATCH 08/11] default sancho image comes from global config now --- application/controllers/jobs/AntragJob.php | 4 ++-- application/controllers/jobs/ReihungstestJob.php | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/application/controllers/jobs/AntragJob.php b/application/controllers/jobs/AntragJob.php index 46a31f3d6..11b950174 100644 --- a/application/controllers/jobs/AntragJob.php +++ b/application/controllers/jobs/AntragJob.php @@ -183,8 +183,8 @@ class AntragJob extends JOB_Controller $data, $to, 'Anträge - Aktion(en) erforderlich', - DEFAULT_SANCHO_HEADER_IMG, - DEFAULT_SANCHO_FOOTER_IMG, + '', + '', '', $cc )) diff --git a/application/controllers/jobs/ReihungstestJob.php b/application/controllers/jobs/ReihungstestJob.php index b55287439..996354bb5 100644 --- a/application/controllers/jobs/ReihungstestJob.php +++ b/application/controllers/jobs/ReihungstestJob.php @@ -431,8 +431,8 @@ class ReihungstestJob extends JOB_Controller $mailcontent_data_arr, $applicant->email, 'Ihre Anmeldung zum Reihungstest - Reminder / Your registration for the placement test - Reminder', - DEFAULT_SANCHO_HEADER_IMG, - DEFAULT_SANCHO_FOOTER_IMG, + '', + '', $from, '', $bcc); From e65322965fd750fe38b1438eb10632106e103d7a Mon Sep 17 00:00:00 2001 From: Alexei Karpenko Date: Mon, 20 Jan 2025 16:24:56 +0100 Subject: [PATCH 09/11] sancho mail: added config for haeder/footer image path, renamed custom mail config entries to sancho mail config entries, images are always attached inline (when using Code Igniter) --- application/config/mail.php | 9 ++++--- application/helpers/hlp_sancho_helper.php | 31 +++++++++++++++++------ config/global.config-default.inc.php | 9 ++++--- include/sancho.inc.php | 17 ++++++------- 4 files changed, 43 insertions(+), 23 deletions(-) diff --git a/application/config/mail.php b/application/config/mail.php index c89400ed1..2ac9a53c3 100644 --- a/application/config/mail.php +++ b/application/config/mail.php @@ -34,10 +34,13 @@ $config['validate'] = false; // If true then the email address will be validated $config['enable_debug'] = false; // If to use images for custom mails -$config['custom_mail_use_images'] = CUSTOM_MAIL_USE_IMAGES; +$config['sancho_mail_use_images'] = SANCHO_MAIL_USE_IMAGES; + +// image path for sancho mail, relativ to document root +$config['sancho_mail_img_path'] = SANCHO_MAIL_IMG_PATH; // header image for custom mails -$config['custom_mail_header_img'] = CUSTOM_MAIL_HEADER_IMG; +$config['sancho_mail_header_img'] = SANCHO_MAIL_HEADER_IMG; // footer image for custom mails -$config['custom_mail_footer_img'] = CUSTOM_MAIL_FOOTER_IMG; +$config['sancho_mail_footer_img'] = SANCHO_MAIL_FOOTER_IMG; diff --git a/application/helpers/hlp_sancho_helper.php b/application/helpers/hlp_sancho_helper.php index d11b6522e..768447eb2 100644 --- a/application/helpers/hlp_sancho_helper.php +++ b/application/helpers/hlp_sancho_helper.php @@ -51,7 +51,7 @@ function sendSanchoMail( $ci->load->library('email'); $ci->load->library('MailLib'); - $custom_mail_use_images = $ci->config->item('mail'); + $sancho_mail_use_images = $ci->config->item('mail'); if ($from == '') @@ -66,7 +66,7 @@ function sendSanchoMail( $cid_header = ''; $cid_footer = ''; - if (isset($custom_mail_use_images['custom_mail_use_images']) && $custom_mail_use_images['custom_mail_use_images']) + if (isset($sancho_mail_use_images['sancho_mail_use_images']) && $sancho_mail_use_images['sancho_mail_use_images']) { $sanchoHeader_img = ''; $sanchoFooter_img = ''; @@ -76,10 +76,10 @@ function sendSanchoMail( // use provided header image $sanchoHeader_img = $headerImg; } - elseif (isset($custom_mail_use_images['custom_mail_header_img']) && $custom_mail_use_images['custom_mail_header_img']) + elseif (isset($sancho_mail_use_images['sancho_mail_header_img']) && $sancho_mail_use_images['sancho_mail_header_img']) { // use default header image - $sanchoHeader_img = 'skin/images/sancho/'. $custom_mail_use_images['custom_mail_header_img']; + $sanchoHeader_img = $sancho_mail_use_images['sancho_mail_header_img']; } if (isset($footerImg) && $footerImg != '') @@ -87,14 +87,29 @@ function sendSanchoMail( // use provided footer image $sanchoFooter_img = $footerImg; } - elseif (isset($custom_mail_use_images['custom_mail_footer_img']) && $custom_mail_use_images['custom_mail_footer_img']) + elseif (isset($sancho_mail_use_images['sancho_mail_footer_img']) && $sancho_mail_use_images['sancho_mail_footer_img']) { // use default footer image - $sanchoFooter_img = 'skin/images/sancho/'. $custom_mail_use_images['custom_mail_footer_img']; + $sanchoFooter_img = $sancho_mail_use_images['sancho_mail_footer_img']; } - $ci->email->attach($sanchoHeader_img); - $ci->email->attach($sanchoFooter_img); + // add image file paths + if (isset($sancho_mail_use_images['sancho_mail_img_path'])) + { + if ($sanchoHeader_img != '') + { + $sanchoHeader_img = $sancho_mail_use_images['sancho_mail_img_path'].$sanchoHeader_img; + } + + if ($sanchoFooter_img != '') + { + $sanchoFooter_img = $sancho_mail_use_images['sancho_mail_img_path'].$sanchoFooter_img; + } + } + + // attach header and footer + $ci->email->attach($sanchoHeader_img, 'inline'); + $ci->email->attach($sanchoFooter_img, 'inline'); $cid_header = $ci->email->attachment_cid($sanchoHeader_img); // sets unique content id for embedding $cid_footer = $ci->email->attachment_cid($sanchoFooter_img); // sets unique content id for embedding } diff --git a/config/global.config-default.inc.php b/config/global.config-default.inc.php index 9446bf5ba..bb9ec0069 100644 --- a/config/global.config-default.inc.php +++ b/config/global.config-default.inc.php @@ -340,11 +340,14 @@ define('DIENSTVERHAELTNIS_SUPPORT', false); define('FAS_STUDSTATUS_SHOW_KOMM_PRFG_HINT', false); // header und footer Bilder für eigene Mails verwenden -define('CUSTOM_MAIL_USE_IMAGES', true); +define('SANCHO_MAIL_USE_IMAGES', true); + +// Pfad für Bilder für eigene Mails, relativ zu document root +define('SANCHO_MAIL_IMG_PATH', 'skin/images/sancho/'); // header Bild für eigene Mails -define('CUSTOM_MAIL_HEADER_IMG', 'sancho_header_DEFAULT.jpg'); +define('SANCHO_MAIL_HEADER_IMG', 'sancho_header_DEFAULT.jpg'); // footer image for eigene Mails -define('CUSTOM_MAIL_FOOTER_IMG', 'sancho_footer_DEFAULT.jpg'); +define('SANCHO_MAIL_FOOTER_IMG', 'sancho_footer_DEFAULT.jpg'); ?> diff --git a/include/sancho.inc.php b/include/sancho.inc.php index 4fdf467e0..e5a9d172f 100644 --- a/include/sancho.inc.php +++ b/include/sancho.inc.php @@ -43,30 +43,29 @@ function sendSanchoMail($vorlage_kurzbz, $vorlage_data, $to, $subject, $headerIm { $from = DEFAULT_SENDER.'@'. DOMAIN; - $header_image_path_prefix = dirname(__FILE__). '/../skin/images/sancho/'; - $footer_image_path_prefix = dirname(__FILE__). '/../skin/images/sancho/'; + $image_path_prefix = dirname(__DIR__).'/'.(defined('SANCHO_MAIL_IMG_PATH') ? SANCHO_MAIL_IMG_PATH : ''); $sanchoHeader_img = ''; $sanchoFooter_img = ''; $cid_header = ''; $cid_footer = ''; - if (!defined('CUSTOM_MAIL_USE_IMAGES') || CUSTOM_MAIL_USE_IMAGES) + if (!defined('SANCHO_MAIL_USE_IMAGES') || SANCHO_MAIL_USE_IMAGES) { if (isset($headerImg) && $headerImg != '') { // use provided header image $sanchoHeader_img = $headerImg; } - elseif (defined('CUSTOM_MAIL_HEADER_IMG') && CUSTOM_MAIL_HEADER_IMG != '') + elseif (defined('SANCHO_MAIL_HEADER_IMG') && SANCHO_MAIL_HEADER_IMG != '') { // use default header image - $sanchoHeader_img = CUSTOM_MAIL_HEADER_IMG; + $sanchoHeader_img = SANCHO_MAIL_HEADER_IMG; } if ($sanchoHeader_img != '') { // set full image path - $sanchoHeader_img = $header_image_path_prefix.$sanchoHeader_img; + $sanchoHeader_img = $image_path_prefix.$sanchoHeader_img; } if (isset($footerImg) && $footerImg != '') @@ -74,16 +73,16 @@ function sendSanchoMail($vorlage_kurzbz, $vorlage_data, $to, $subject, $headerIm // use provided footer image $sanchoFooter_img = $footerImg; } - elseif (defined('CUSTOM_MAIL_FOOTER_IMG') && CUSTOM_MAIL_FOOTER_IMG != '') + elseif (defined('SANCHO_MAIL_FOOTER_IMG') && SANCHO_MAIL_FOOTER_IMG != '') { // use default footer image - $sanchoFooter_img = CUSTOM_MAIL_FOOTER_IMG; + $sanchoFooter_img = SANCHO_MAIL_FOOTER_IMG; } if ($sanchoFooter_img !== '') { // set full image path - $sanchoFooter_img = $footer_image_path_prefix.$sanchoFooter_img; + $sanchoFooter_img = $image_path_prefix.$sanchoFooter_img; } // Set unique content id for embedding header and footer image From 39c2e447198849460a36eac85938896534e1f0f1 Mon Sep 17 00:00:00 2001 From: Harald Bamberger Date: Tue, 28 Jan 2025 10:22:30 +0100 Subject: [PATCH 10/11] 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 = ''; From 7f6744047f18ee07b3065d8a89d94e28e123d917 Mon Sep 17 00:00:00 2001 From: Harald Bamberger Date: Tue, 28 Jan 2025 11:26:01 +0100 Subject: [PATCH 11/11] check in ci mail config if constants in global config are defined --- application/config/mail.php | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/application/config/mail.php b/application/config/mail.php index e7fd53c3a..4f1baa85d 100644 --- a/application/config/mail.php +++ b/application/config/mail.php @@ -34,16 +34,16 @@ $config['validate'] = false; // If true then the email address will be validated $config['enable_debug'] = false; // default sender -$config['sancho_mail_default_sender'] = SANCHO_MAIL_DEFAULT_SENDER; +$config['sancho_mail_default_sender'] = defined('SANCHO_MAIL_DEFAULT_SENDER') ? SANCHO_MAIL_DEFAULT_SENDER : ''; // If to use images for custom mails -$config['sancho_mail_use_images'] = SANCHO_MAIL_USE_IMAGES; +$config['sancho_mail_use_images'] = defined('SANCHO_MAIL_USE_IMAGES') ? SANCHO_MAIL_USE_IMAGES : false; // image path for sancho mail, relativ to document root -$config['sancho_mail_img_path'] = SANCHO_MAIL_IMG_PATH; +$config['sancho_mail_img_path'] = defined('SANCHO_MAIL_IMG_PATH') ? SANCHO_MAIL_IMG_PATH : ''; // header image for custom mails -$config['sancho_mail_header_img'] = SANCHO_MAIL_HEADER_IMG; +$config['sancho_mail_header_img'] = defined('SANCHO_MAIL_HEADER_IMG') ? SANCHO_MAIL_HEADER_IMG : ''; // footer image for custom mails -$config['sancho_mail_footer_img'] = SANCHO_MAIL_FOOTER_IMG; +$config['sancho_mail_footer_img'] = defined('SANCHO_MAIL_FOOTER_IMG') ? SANCHO_MAIL_FOOTER_IMG : '';