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:
parent
a648e34b67
commit
168c177fb5
@ -1992,6 +1992,8 @@ class SMTPs
|
|||||||
{
|
{
|
||||||
$content = 'Content-Type: multipart/mixed;' . "\r\n"
|
$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"
|
||||||
. "\r\n--" . $this->_getBoundary() . "\r\n"
|
. "\r\n--" . $this->_getBoundary() . "\r\n"
|
||||||
. 'Content-Type: multipart/related;' . "\r\n"
|
. 'Content-Type: multipart/related;' . "\r\n"
|
||||||
. ' boundary="' . $this->_getRelatedBoundary() . '"' . "\r\n";
|
. ' boundary="' . $this->_getRelatedBoundary() . '"' . "\r\n";
|
||||||
@ -1999,7 +2001,9 @@ class SMTPs
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
$content = 'Content-Type: multipart/mixed;' . "\r\n"
|
$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;
|
$attachment=1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -2016,9 +2020,8 @@ class SMTPs
|
|||||||
//$content = 'Content-Type: multipart/mixed;' . "\r\n"
|
//$content = 'Content-Type: multipart/mixed;' . "\r\n"
|
||||||
// . ' boundary="' . $this->_getBoundary() . '"' . "\r\n"
|
// . ' boundary="' . $this->_getBoundary() . '"' . "\r\n"
|
||||||
// . "\r\n"
|
// . "\r\n"
|
||||||
$content .= "\r\n"
|
// . 'This is a multi-part message in MIME format.' . "\r\n";
|
||||||
// END DOL_CHANGE LDR
|
// END DOL_CHANGE LDR
|
||||||
. 'This is a multi-part message in MIME format.' . "\r\n";
|
|
||||||
|
|
||||||
// Loop through message content array
|
// Loop through message content array
|
||||||
foreach ($this->_msgContent as $type => $_content )
|
foreach ($this->_msgContent as $type => $_content )
|
||||||
@ -2089,9 +2092,10 @@ class SMTPs
|
|||||||
//$content .= ( $type == 'html') ? '; name="HTML Part"' : ''; // DOL_CHANGE LDR
|
//$content .= ( $type == 'html') ? '; name="HTML Part"' : ''; // DOL_CHANGE LDR
|
||||||
$content .= "\r\n";
|
$content .= "\r\n";
|
||||||
$content .= 'Content-Transfer-Encoding: ';
|
$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 .= "\r\n"
|
||||||
. 'Content-Disposition: inline' . "\r\n"
|
//. 'Content-Disposition: inline' . "\r\n"
|
||||||
. 'Content-Description: ' . $type . ' message' . "\r\n";
|
. 'Content-Description: ' . $type . ' message' . "\r\n";
|
||||||
|
|
||||||
if ( $this->getMD5flag() )
|
if ( $this->getMD5flag() )
|
||||||
@ -2568,6 +2572,11 @@ class SMTPs
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* $Log$
|
* $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
|
* Revision 1.4 2009/05/12 08:39:40 hregis
|
||||||
* Add: possibilité d'envoyer un fichier attaché avec du html contenant des images avec
|
* Add: possibilité d'envoyer un fichier attaché avec du html contenant des images avec
|
||||||
* la classe SMTPS
|
* la classe SMTPS
|
||||||
|
|||||||
@ -92,8 +92,8 @@ class CMailFile
|
|||||||
// Evite caractere bizarre avec les accents
|
// Evite caractere bizarre avec les accents
|
||||||
//Todo l'envoi par mailing donne des caractères bizarre,
|
//Todo l'envoi par mailing donne des caractères bizarre,
|
||||||
// alors que l'envoi d'un document facture ou autre est correcte
|
// alors que l'envoi d'un document facture ou autre est correcte
|
||||||
//$subject = utf8_decode($subject);
|
$subject = utf8_decode($subject);
|
||||||
//$from = utf8_decode($from);
|
$from = utf8_decode($from);
|
||||||
|
|
||||||
// If ending method not defined
|
// If ending method not defined
|
||||||
if (empty($conf->global->MAIN_MAIL_SENDMODE)) $conf->global->MAIN_MAIL_SENDMODE='mail';
|
if (empty($conf->global->MAIN_MAIL_SENDMODE)) $conf->global->MAIN_MAIL_SENDMODE='mail';
|
||||||
@ -219,6 +219,7 @@ class CMailFile
|
|||||||
$smtps->setTO($to);
|
$smtps->setTO($to);
|
||||||
$smtps->setFrom($from);
|
$smtps->setFrom($from);
|
||||||
if ($this->atleastoneimage) $msg = $this->html;
|
if ($this->atleastoneimage) $msg = $this->html;
|
||||||
|
$msg = $this->checkIfHTML($msg);
|
||||||
if ($this->msgishtml) $smtps->setBodyContent($msg,'html');
|
if ($this->msgishtml) $smtps->setBodyContent($msg,'html');
|
||||||
else $smtps->setBodyContent($msg,'plain');
|
else $smtps->setBodyContent($msg,'plain');
|
||||||
|
|
||||||
@ -573,12 +574,8 @@ class CMailFile
|
|||||||
if ($this->msgishtml)
|
if ($this->msgishtml)
|
||||||
{
|
{
|
||||||
// Check if html header already in message
|
// Check if html header already in message
|
||||||
$htmlalreadyinmsg=0;
|
$out.= $this->checkIfHTML($msgtext);
|
||||||
if (eregi('^[ \t]*<html',$msgtext)) $htmlalreadyinmsg=1;
|
|
||||||
|
|
||||||
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)
|
||||||
{
|
{
|
||||||
if ($this->atleastonefile && $this->atleastoneimage)
|
if ($this->atleastonefile && $this->atleastoneimage)
|
||||||
@ -603,6 +600,22 @@ class CMailFile
|
|||||||
return $out;
|
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
|
\brief Permet d'attacher un fichier
|
||||||
\param filename_list Tableau
|
\param filename_list Tableau
|
||||||
@ -774,7 +787,7 @@ class CMailFile
|
|||||||
$this->images_encoded[$i]['cid'] = $img["cid"];
|
$this->images_encoded[$i]['cid'] = $img["cid"];
|
||||||
|
|
||||||
// Encodage de l'image
|
// 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++;
|
$i++;
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user