Add option MAIN_MAIL_EMAIL_INLINE_IMAGES to activate inline attachment because inline attachment not supported by all mails readers and antispams.
This commit is contained in:
parent
3bc32b37c5
commit
adec798069
@ -113,13 +113,13 @@ class CMailFile
|
||||
if (preg_match('/^mac/i',PHP_OS)) $this->eol="\r";
|
||||
|
||||
// On defini mixed_boundary
|
||||
$this->mixed_boundary = md5(uniqid("dolibarr"));
|
||||
$this->mixed_boundary = md5(uniqid("dolibarr1"));
|
||||
|
||||
// On defini related_boundary
|
||||
$this->related_boundary = md5(uniqid("dolibarr"));
|
||||
$this->related_boundary = md5(uniqid("dolibarr2"));
|
||||
|
||||
// On defini alternative_boundary
|
||||
$this->alternative_boundary = md5(uniqid("dolibarr"));
|
||||
$this->alternative_boundary = md5(uniqid("dolibarr3"));
|
||||
|
||||
// If ending method not defined
|
||||
if (empty($conf->global->MAIN_MAIL_SENDMODE)) $conf->global->MAIN_MAIL_SENDMODE='mail';
|
||||
@ -207,13 +207,13 @@ class CMailFile
|
||||
|
||||
// Define body in text_body
|
||||
$text_body = $this->write_body($msg);
|
||||
$text_body.= "--" . $this->alternative_boundary . "--" . $this->eol;
|
||||
if (! empty($conf->global->MAIN_MAIL_EMAIL_INLINE_IMAGES)) $text_body.= "--" . $this->alternative_boundary . "--" . $this->eol;
|
||||
|
||||
// Encode images
|
||||
if ($this->atleastoneimage)
|
||||
{
|
||||
$images_encoded = $this->write_images($this->images_encoded);
|
||||
$images_encoded.= "--" . $this->related_boundary . "--" . $this->eol;
|
||||
if (! empty($conf->global->MAIN_MAIL_EMAIL_INLINE_IMAGES)) $images_encoded.= "--" . $this->related_boundary . "--" . $this->eol;
|
||||
}
|
||||
|
||||
// Add attachments to text_encoded
|
||||
@ -603,21 +603,24 @@ class CMailFile
|
||||
$out.= "Content-Type: multipart/mixed; boundary=\"".$this->mixed_boundary."\"".$this->eol;
|
||||
$out.= "Content-Transfer-Encoding: 8bit".$this->eol;
|
||||
|
||||
if ($this->atleastoneimage)
|
||||
if (! empty($conf->global->MAIN_MAIL_EMAIL_INLINE_IMAGES))
|
||||
{
|
||||
$out.= "--" . $this->mixed_boundary . $this->eol;
|
||||
$out.= "Content-Type: multipart/related; boundary=\"".$this->related_boundary."\"".$this->eol;
|
||||
if ($this->atleastoneimage)
|
||||
{
|
||||
$out.= "--" . $this->mixed_boundary . $this->eol;
|
||||
$out.= "Content-Type: multipart/related; boundary=\"".$this->related_boundary."\"".$this->eol;
|
||||
$out.= $this->eol;
|
||||
$out.= "--" . $this->related_boundary . $this->eol;
|
||||
}
|
||||
else
|
||||
{
|
||||
$out.= "--" . $this->mixed_boundary . $this->eol;
|
||||
}
|
||||
|
||||
$out.= "Content-Type: multipart/alternative; boundary=\"".$this->alternative_boundary."\"".$this->eol;
|
||||
$out.= $this->eol;
|
||||
$out.= "--" . $this->related_boundary . $this->eol;
|
||||
}
|
||||
else
|
||||
{
|
||||
$out.= "--" . $this->mixed_boundary . $this->eol;
|
||||
}
|
||||
|
||||
$out.= "Content-Type: multipart/alternative; boundary=\"".$this->alternative_boundary."\"".$this->eol;
|
||||
$out.= $this->eol;
|
||||
|
||||
//$out.=$this->eol; // Comment this to try to solve pb of hidden attached files. New line must be after the X-attachments
|
||||
dol_syslog("CMailFile::write_smtpheaders smtp_header=\n".$out);
|
||||
return $out;
|
||||
@ -666,12 +669,14 @@ class CMailFile
|
||||
|
||||
if ($this->msgishtml)
|
||||
{
|
||||
$out.= "--" . $this->alternative_boundary . $this->eol;
|
||||
if (! empty($conf->global->MAIN_MAIL_EMAIL_INLINE_IMAGES)) $out.= "--" . $this->alternative_boundary . $this->eol;
|
||||
else $out.= "--" . $this->mixed_boundary . $this->eol;
|
||||
$out.= "Content-Type: text/html; charset=".$conf->file->character_set_client.$this->eol;
|
||||
}
|
||||
else
|
||||
{
|
||||
$out.= "--" . $this->alternative_boundary . $this->eol;
|
||||
if (! empty($conf->global->MAIN_MAIL_EMAIL_INLINE_IMAGES)) $out.= "--" . $this->alternative_boundary . $this->eol;
|
||||
else $out.= "--" . $this->mixed_boundary . $this->eol;
|
||||
$out.= "Content-Type: text/plain; charset=".$conf->file->character_set_client.$this->eol;
|
||||
}
|
||||
$out.= $this->eol;
|
||||
@ -693,7 +698,7 @@ class CMailFile
|
||||
$strContent = rtrim(wordwrap($strContent));
|
||||
|
||||
$out.= $strContent.$this->eol;
|
||||
$out.= $this->eol;
|
||||
if (! empty($conf->global->MAIN_MAIL_EMAIL_INLINE_IMAGES)) $out.= $this->eol;
|
||||
|
||||
return $out;
|
||||
}
|
||||
@ -759,7 +764,8 @@ class CMailFile
|
||||
{
|
||||
dol_syslog("CMailFile::write_images: i=$i");
|
||||
|
||||
$out.= "--" . $this->related_boundary . $this->eol;
|
||||
if (! empty($conf->global->MAIN_MAIL_EMAIL_INLINE_IMAGES)) $out.= "--" . $this->related_boundary . $this->eol;
|
||||
else $out.= "--" . $this->mixed_boundary . $this->eol;
|
||||
$out.= "Content-Type: " . $img["content_type"] . "; name=\"".$img["name"]."\"".$this->eol;
|
||||
$out.= "Content-Transfer-Encoding: base64".$this->eol;
|
||||
$out.= "Content-Disposition: inline; filename=\"".$img["name"]."\"".$this->eol;
|
||||
|
||||
Loading…
Reference in New Issue
Block a user