Add: possibilit d'envoyer un fichier attach avec du html contenant des images avec

la classe SMTPS
Fix: 'quoted-printable' truncated html code
This commit is contained in:
Regis Houssin 2009-05-12 10:12:02 +00:00
parent a648e34b67
commit 168c177fb5
2 changed files with 36 additions and 14 deletions

View File

@ -1992,6 +1992,8 @@ class SMTPs
{
$content = 'Content-Type: multipart/mixed;' . "\r\n"
. ' boundary="' . $this->_getBoundary() . '"' . "\r\n"
. "\r\n"
. 'This is a multi-part message in MIME format.' . "\r\n"
. "\r\n--" . $this->_getBoundary() . "\r\n"
. 'Content-Type: multipart/related;' . "\r\n"
. ' boundary="' . $this->_getRelatedBoundary() . '"' . "\r\n";
@ -1999,7 +2001,9 @@ class SMTPs
else
{
$content = 'Content-Type: multipart/mixed;' . "\r\n"
. ' boundary="' . $this->_getBoundary() . '"' . "\r\n";
. ' boundary="' . $this->_getBoundary() . '"' . "\r\n"
. "\r\n"
. 'This is a multi-part message in MIME format.' . "\r\n";
$attachment=1;
}
}
@ -2016,9 +2020,8 @@ class SMTPs
//$content = 'Content-Type: multipart/mixed;' . "\r\n"
// . ' boundary="' . $this->_getBoundary() . '"' . "\r\n"
// . "\r\n"
$content .= "\r\n"
// END DOL_CHANGE LDR
. 'This is a multi-part message in MIME format.' . "\r\n";
// . 'This is a multi-part message in MIME format.' . "\r\n";
// END DOL_CHANGE LDR
// Loop through message content array
foreach ($this->_msgContent as $type => $_content )
@ -2089,9 +2092,10 @@ class SMTPs
//$content .= ( $type == 'html') ? '; name="HTML Part"' : ''; // DOL_CHANGE LDR
$content .= "\r\n";
$content .= 'Content-Transfer-Encoding: ';
$content .= ( $type == 'html') ? 'quoted-printable' : $this->getTransEncodeType();
//$content .= ( $type == 'html') ? 'quoted-printable' : $this->getTransEncodeType(); // DOL_CHANGE LDR
$content .= ( $type == 'html') ? '8bit' : $this->getTransEncodeType();
$content .= "\r\n"
. 'Content-Disposition: inline' . "\r\n"
//. 'Content-Disposition: inline' . "\r\n"
. 'Content-Description: ' . $type . ' message' . "\r\n";
if ( $this->getMD5flag() )
@ -2568,6 +2572,11 @@ class SMTPs
/**
* $Log$
* Revision 1.5 2009/05/12 10:12:02 hregis
* Add: possibilité d'envoyer un fichier attaché avec du html contenant des images avec
* la classe SMTPS
* Fix: 'quoted-printable' truncated html code
*
* Revision 1.4 2009/05/12 08:39:40 hregis
* Add: possibilité d'envoyer un fichier attaché avec du html contenant des images avec
* la classe SMTPS

View File

@ -92,8 +92,8 @@ class CMailFile
// Evite caractere bizarre avec les accents
//Todo l'envoi par mailing donne des caractères bizarre,
// alors que l'envoi d'un document facture ou autre est correcte
//$subject = utf8_decode($subject);
//$from = utf8_decode($from);
$subject = utf8_decode($subject);
$from = utf8_decode($from);
// If ending method not defined
if (empty($conf->global->MAIN_MAIL_SENDMODE)) $conf->global->MAIN_MAIL_SENDMODE='mail';
@ -219,6 +219,7 @@ class CMailFile
$smtps->setTO($to);
$smtps->setFrom($from);
if ($this->atleastoneimage) $msg = $this->html;
$msg = $this->checkIfHTML($msg);
if ($this->msgishtml) $smtps->setBodyContent($msg,'html');
else $smtps->setBodyContent($msg,'plain');
@ -573,12 +574,8 @@ class CMailFile
if ($this->msgishtml)
{
// Check if html header already in message
$htmlalreadyinmsg=0;
if (eregi('^[ \t]*<html',$msgtext)) $htmlalreadyinmsg=1;
$out.= $this->checkIfHTML($msgtext);
if (! $htmlalreadyinmsg) $out .= "<html><head><title></title></head><body>";
$out.= $msgtext;
if (! $htmlalreadyinmsg) $out .= "</body></html>";
if ($this->atleastonefile || $this->atleastoneimage)
{
if ($this->atleastonefile && $this->atleastoneimage)
@ -602,6 +599,22 @@ class CMailFile
return $out;
}
function checkIfHTML($msg)
{
if (!eregi('^[ \t]*<html',$msg))
{
$out = "<html><head><title></title></head><body>";
$out.= $msg;
$out.= "</body></html>";
}
else
{
$out = $msg;
}
return $out;
}
/**
\brief Permet d'attacher un fichier
@ -774,7 +787,7 @@ class CMailFile
$this->images_encoded[$i]['cid'] = $img["cid"];
// Encodage de l'image
$this->images_encoded[$i]["image_encoded"] = chunk_split(base64_encode($image), 68, $this->eol);
$this->images_encoded[$i]["image_encoded"] = rtrim(chunk_split(base64_encode($image), 68, $this->eol));
}
$i++;
}