diff --git a/htdocs/lib/CMailFile.class.php b/htdocs/lib/CMailFile.class.php index fd8080b0948..c81bbdbc572 100644 --- a/htdocs/lib/CMailFile.class.php +++ b/htdocs/lib/CMailFile.class.php @@ -143,12 +143,6 @@ class CMailFile // On defini mime_boundary $this->mime_boundary = md5(uniqid("dolibarr")); - - // On defini image_boundary - $this->image_boundary = md5(uniqid(time())); - - // On defini alternative_boundary - $this->alternative_boundary = md5(uniqid(time())); // On definit fin de ligne $this->eol="\n"; @@ -161,7 +155,7 @@ class CMailFile $text_encoded = ""; // En-tete dans $smtp_headers - $this->subject = $subject; + $this->subject = utf8_decode($subject); $this->addr_from = $from; $this->errors_to = $errors_to; $this->addr_to = $to; @@ -460,18 +454,22 @@ class CMailFile if (isset($this->deliveryreceipt) && $this->deliveryreceipt == 1) $out .= "Disposition-Notification-To: ".getValidAddress($this->addr_from,2).$this->eol; //$out .= "X-Priority: 3".$this->eol; - $out .= "X-Mailer: Dolibarr version " . DOL_VERSION ." (using php mail)".$this->eol; - $out .= "MIME-Version: 1.0".$this->eol; - - if ($this->msgishtml) + $out.= "X-Mailer: Dolibarr version " . DOL_VERSION ." (using php mail)".$this->eol; + $out.= "MIME-Version: 1.0".$this->eol; + + if ($this->atleastoneimage) { - $out.= "Content-Type: multipart/alternative; boundary=\"".$this->alternative_boundary."\"".$this->eol; - if (! $this->atleastonefile) $out.= "Content-Type: text/html; charset=".$conf->file->character_set_client.$this->eol; + if (! $this->atleastonefile) $out.= "Content-Type: multipart/related; boundary=\"".$this->mime_boundary."\"".$this->eol; + $out.= "Content-Transfer-Encoding: 8bit".$this->eol; + } + else if ($this->msgishtml) + { + if (! $this->atleastonefile) $out.= "Content-Type: text/html; boundary=\"".$this->mime_boundary."\"".$this->eol; $out.= "Content-Transfer-Encoding: 8bit".$this->eol; } else { - if (! $this->atleastonefile) $out.= "Content-Type: text/plain; charset=".$conf->file->character_set_client.$this->eol; + if (! $this->atleastonefile) $out.= "Content-Type: text/plain; boundary=\"".$this->mime_boundary."\"".$this->eol; $out.= "Content-Transfer-Encoding: 8bit".$this->eol; } @@ -507,11 +505,6 @@ class CMailFile } } - if ($this->atleastoneimage) - { - $out.= "Content-Type: multipart/related; boundary=\"".$this->image_boundary."\"".$this->eol; - } - //$out.= $this->eol; dol_syslog("CMailFile::write_mimeheaders mime_header=\n".$out, LOG_DEBUG); return $out; @@ -532,7 +525,7 @@ class CMailFile { if ($this->msgishtml) { - $out.= "--" . $this->alternative_boundary . $this->eol; + $out.= "--" . $this->mime_boundary . $this->eol; $out.= "Content-Type: text/html; charset=".$conf->file->character_set_client.$this->eol; } else @@ -551,12 +544,17 @@ class CMailFile if (! $htmlalreadyinmsg) $out .= "