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)

This commit is contained in:
Alexei Karpenko
2025-01-20 16:24:56 +01:00
parent 899c36c52c
commit e65322965f
4 changed files with 43 additions and 23 deletions
+6 -3
View File
@@ -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;
+23 -8
View File
@@ -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
}
+6 -3
View File
@@ -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');
?>
+8 -9
View File
@@ -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