Add: possibilité d'uploader une image et de l'envoyer dans un mailing

Todo: encore en mode débugage !!
This commit is contained in:
Regis Houssin 2009-05-09 15:43:13 +00:00
parent a6d8e32e3f
commit 27558c273d

View File

@ -147,6 +147,9 @@ class CMailFile
// On defini image_boundary // On defini image_boundary
$this->image_boundary = md5(uniqid(time())); $this->image_boundary = md5(uniqid(time()));
// On defini alternative_boundary
$this->alternative_boundary = md5(uniqid(time()));
// On definit fin de ligne // On definit fin de ligne
$this->eol="\n"; $this->eol="\n";
if (eregi('^win',PHP_OS)) $this->eol="\r\n"; if (eregi('^win',PHP_OS)) $this->eol="\r\n";
@ -462,7 +465,8 @@ class CMailFile
if ($this->msgishtml) if ($this->msgishtml)
{ {
if (! $this->atleastonefile || $this->atleastoneimage) $out.= "Content-Type: text/html; charset=".$conf->file->character_set_client.$this->eol; $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;
$out.= "Content-Transfer-Encoding: 8bit".$this->eol; $out.= "Content-Transfer-Encoding: 8bit".$this->eol;
} }
else else
@ -526,13 +530,14 @@ class CMailFile
if ($this->atleastonefile || $this->atleastoneimage) if ($this->atleastonefile || $this->atleastoneimage)
{ {
$out.= "--" . $this->mime_boundary . $this->eol;
if ($this->msgishtml) if ($this->msgishtml)
{ {
$out.= "--" . $this->alternative_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 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; $out.= $this->eol;
@ -551,8 +556,6 @@ class CMailFile
{ {
$out.= $msgtext; $out.= $msgtext;
} }
$out.= $this->eol . "--" . $this->mime_boundary . "--" . $this->eol;
return $out; return $out;
} }
@ -595,7 +598,7 @@ class CMailFile
} }
// Fin de tous les attachements // Fin de tous les attachements
$out = $out . "--" . $this->mime_boundary . "--" . $this->eol; $out.= "--" . $this->mime_boundary . "--" . $this->eol;
return $out; return $out;
} }
@ -751,7 +754,7 @@ class CMailFile
{ {
dol_syslog("CMailFile::write_images: i=$i"); dol_syslog("CMailFile::write_images: i=$i");
$out = $out . "--" . $this->image_boundary . $this->eol; $out.= "--" . $this->image_boundary . $this->eol;
$out.= "Content-Type: " . $img["content_type"] . "; name=\"".$img["name"]."\"".$this->eol; $out.= "Content-Type: " . $img["content_type"] . "; name=\"".$img["name"]."\"".$this->eol;
$out.= "Content-Transfer-Encoding: base64".$this->eol; $out.= "Content-Transfer-Encoding: base64".$this->eol;
$out.= "Content-ID: <".$img["cid"].">".$this->eol; $out.= "Content-ID: <".$img["cid"].">".$this->eol;
@ -766,7 +769,7 @@ class CMailFile
} }
// Fin de tous les attachements // Fin de tous les attachements
$out.= $this->eol . "--" . $this->image_boundary . "--" . $this->eol; $out.= "--" . $this->image_boundary . "--" . $this->eol;
return $out; return $out;
} }