diff --git a/htdocs/comm/mailing/fiche.php b/htdocs/comm/mailing/fiche.php index ce8bfa31e2a..4f4b7c7d02a 100644 --- a/htdocs/comm/mailing/fiche.php +++ b/htdocs/comm/mailing/fiche.php @@ -288,6 +288,11 @@ if ($_POST["action"] == 'send' && ! $_POST["cancel"]) $arr_file = array(); $arr_mime = array(); $arr_name = array(); + $arr_css = array(); + + // Ajout CSS + if (!empty($mil->bgcolor)) $arr_css['bgcolor'] = $mil->bgcolor; + if (!empty($mil->bgimage)) $arr_css['bgimage'] = $mil->bgimage; // Le message est-il en html $msgishtml=-1; // Inconnu par defaut @@ -298,8 +303,7 @@ if ($_POST["action"] == 'send' && ! $_POST["cancel"]) $mil->body=make_substitutions($mil->body,$substitutionarrayfortest); $mailfile = new CMailFile($mil->sujet,$mil->sendto,$mil->email_from,$mil->body, - $arr_file,$arr_mime,$arr_name, - '', '', 0, $msgishtml); + $arr_file,$arr_mime,$arr_name,'', '', 0, $msgishtml,'',$arr_css); $result=$mailfile->sendfile(); if ($result) diff --git a/htdocs/lib/CMailFile.class.php b/htdocs/lib/CMailFile.class.php index 647415c74aa..0fb7d9cb384 100644 --- a/htdocs/lib/CMailFile.class.php +++ b/htdocs/lib/CMailFile.class.php @@ -60,6 +60,10 @@ class CMailFile var $sName; var $sEmail; + //CSS + var $css; + var $styleCSS; + // Image var $html; var $image_boundary; @@ -87,12 +91,14 @@ class CMailFile * \param mimefilename_list List of attached file name in message * \param addr_cc Email cc * \param addr_bcc Email bcc - * \param deliveryreceipt Ask a delivery receipt - * \param msgishtml 1=String IS already html, 0=String IS NOT html, -1=Unknown need autodetection + * \param deliveryreceipt Ask a delivery receipt + * \param msgishtml 1=String IS already html, 0=String IS NOT html, -1=Unknown need autodetection + * \param error_to Email errors + * \param css Css option */ function CMailFile($subject,$to,$from,$msg, $filename_list=array(),$mimetype_list=array(),$mimefilename_list=array(), - $addr_cc="",$addr_bcc="",$deliveryreceipt=0,$msgishtml=0,$errors_to='') + $addr_cc="",$addr_bcc="",$deliveryreceipt=0,$msgishtml=0,$errors_to='',$css='') { global $conf; @@ -270,7 +276,13 @@ class CMailFile if ($this->msgishtml) { if (! empty($this->html)) - { + { + if (!empty($css)) + { + $this->css = $css; + $this->styleCSS = $this->buildCSS(); + } + $msg = $this->html; $msg = $this->checkIfHTML($msg); @@ -315,9 +327,13 @@ class CMailFile $smtps->setTO($this->getValidAddress($to,2)); $smtps->setFrom($from); - //if ($this->atleastoneimage) $msg = $this->html; if (! empty($this->html)) { + if (!empty($css)) + { + $this->css = $css; + $this->styleCSS = $this->buildCSS(); + } $msg = $this->html; $msg = $this->checkIfHTML($msg); } @@ -639,8 +655,6 @@ class CMailFile $out=''; - // if ($this->atleastonefile || $this->atleastoneimage) - // { if ($this->msgishtml) { $out.= "--" . $this->mime_boundary . $this->eol; @@ -652,39 +666,23 @@ class CMailFile $out.= "Content-Type: text/plain; charset=\"".$conf->file->character_set_client."\"".$this->eol; } $out.= $this->eol; - // } + if ($this->msgishtml) { // Check if html header already in message $strContent = $this->checkIfHTML($msgtext); - - /*if ($this->atleastonefile || $this->atleastoneimage) - { - if ($this->atleastonefile && $this->atleastoneimage) - { - $out.= $this->eol . "--" . $this->related_boundary . $this->eol; - } - else - { - $out.= $this->eol . "--" . $this->mime_boundary . $this->eol; - } - }*/ } else { $strContent.= $msgtext; - /* if ($this->atleastonefile || $this->atleastoneimage) - { - $out.= $this->eol . "--" . $this->mime_boundary . $this->eol; - }*/ } // Make RFC821 Compliant, replace bare linefeeds - $strContent = preg_replace("/(?eol; + $out.=$strContent.$this->eol; return $out; } @@ -695,12 +693,12 @@ class CMailFile * @param unknown_type $msg * @return unknown */ - function checkIfHTML($msg,$css='') + function checkIfHTML($msg) { if (!eregi('^[ \t]*styleCSS)) $out.= $this->styleCSS; $out.= ""; $out.= $msg; $out.= ""; @@ -716,18 +714,30 @@ class CMailFile /** * Build a css style * - * @param $value * @return css */ - function buildCSS($value) + function buildCSS() { - // Todo: finir la construction - $out = ''; - + $out = ''; + + if (!empty($this->css)) + { + $out.= ''; + } + return $out; }