From 0498c6202fa3592d10db146061171055fea4caf9 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 9 Oct 2010 23:17:41 +0000 Subject: [PATCH] Fix: Fixed a very old bug making file attachment fails with some emails readers when using "mail php function". --- ChangeLog | 3 + htdocs/lib/CMailFile.class.php | 126 +++++++++++++++++---------------- 2 files changed, 68 insertions(+), 61 deletions(-) diff --git a/ChangeLog b/ChangeLog index 6bf50508b35..a081fafb5c4 100644 --- a/ChangeLog +++ b/ChangeLog @@ -43,6 +43,9 @@ For users: - Fix: Database name can contains "-" characters. - Fix: In coloring negative amounts. - Fix: Date input use date format of user and not dd/mm/yyyy format. +- Fix: Fixed a very old bug making file attachment fails with some emails + readers when using "mail php function". + For translators: - New: Update and complete slovenian language sl_SL. diff --git a/htdocs/lib/CMailFile.class.php b/htdocs/lib/CMailFile.class.php index 2c51bbcaffb..f32ad36dbe4 100644 --- a/htdocs/lib/CMailFile.class.php +++ b/htdocs/lib/CMailFile.class.php @@ -475,7 +475,8 @@ class CMailFile /** - * Ecrit le mail dans un fichier. Utilisation pour le debuggage. + * Write content of a SMTP request into a dump file (mode = all) + * Used for debugging. */ function dump_mail() { @@ -502,8 +503,64 @@ class CMailFile } } + + /** + * Correct an uncomplete html string + * + * @param $msg + * @return + */ + function checkIfHTML($msg) + { + if (!preg_match('/^[\s\t]*styleCSS)) $out.= $this->styleCSS; + $out.= "bodyCSS)) $out.= $this->bodyCSS; + $out.= ">"; + $out.= $msg; + $out.= ""; + } + else + { + $out = $msg; + } + + return $out; + } + + /** + * Build a css style (mode = all) + * + * @return css + */ + function buildCSS() + { + if (! empty($this->css)) + { + // Style CSS + $this->styleCSS = ''; + } + } + + /** - * Create SMTP headers + * Create SMTP headers (mode = 'mail') * * @return smtp headers */ @@ -583,12 +640,12 @@ class CMailFile if ($this->msgishtml) { $out.= "--" . $this->mime_boundary . $this->eol; - $out.= "Content-Type: text/html; charset=\"".$conf->file->character_set_client."\"".$this->eol; + $out.= "Content-Type: text/html; charset=".$conf->file->character_set_client.$this->eol; } else { $out.= "--" . $this->mime_boundary . $this->eol; - $out.= "Content-Type: text/plain; charset=\"".$conf->file->character_set_client."\"".$this->eol; + $out.= "Content-Type: text/plain; charset=".$conf->file->character_set_client.$this->eol; } $out.= $this->eol; @@ -605,67 +662,14 @@ class CMailFile // Make RFC821 Compliant, replace bare linefeeds $strContent = preg_replace("/(?eol; return $out; } - /** - * Correct an uncomplete html string - * - * @param $msg - * @return - */ - function checkIfHTML($msg) - { - if (!preg_match('/^[\s\t]*styleCSS)) $out.= $this->styleCSS; - $out.= "bodyCSS)) $out.= $this->bodyCSS; - $out.= ">"; - $out.= $msg; - $out.= ""; - } - else - { - $out = $msg; - } - - return $out; - } - - /** - * Build a css style - * - * @return css - */ - function buildCSS() - { - if (! empty($this->css)) - { - // Style CSS - $this->styleCSS = ''; - } - } - /** * Permet d'attacher un fichier (mode = 'mail') * @@ -691,10 +695,10 @@ class CMailFile if (! $mimetype_list[$i]) { $mimetype_list[$i] = "application/octet-stream"; } $out.= "--" . $this->mime_boundary . $this->eol; + $out.= "Content-Disposition: attachment; filename=\"".$filename_list[$i]."\"".$this->eol; $out.= "Content-Type: " . $mimetype_list[$i] . "; name=\"".$filename_list[$i]."\"".$this->eol; $out.= "Content-Transfer-Encoding: base64".$this->eol; - $out.= "Content-Disposition: attachment; filename=\"".$filename_list[$i]."\"".$this->eol; - $out.= "Content-Description: \""."File Attachment"."\"".$this->eol; + $out.= "Content-Description: File Attachment".$this->eol; $out.= $this->eol; $out.= $encoded; $out.= $this->eol;