Skip to content
Snippets Groups Projects
Commit adec7980 authored by Laurent Destailleur's avatar Laurent Destailleur
Browse files

Add option MAIN_MAIL_EMAIL_INLINE_IMAGES to activate inline attachment because...

Add option MAIN_MAIL_EMAIL_INLINE_IMAGES to activate inline attachment because inline attachment not supported by all mails readers and antispams.
parent 3bc32b37
Branches solution
No related tags found
No related merge requests found
...@@ -113,13 +113,13 @@ class CMailFile ...@@ -113,13 +113,13 @@ class CMailFile
if (preg_match('/^mac/i',PHP_OS)) $this->eol="\r"; if (preg_match('/^mac/i',PHP_OS)) $this->eol="\r";
// On defini mixed_boundary // On defini mixed_boundary
$this->mixed_boundary = md5(uniqid("dolibarr")); $this->mixed_boundary = md5(uniqid("dolibarr1"));
// On defini related_boundary // On defini related_boundary
$this->related_boundary = md5(uniqid("dolibarr")); $this->related_boundary = md5(uniqid("dolibarr2"));
// On defini alternative_boundary // On defini alternative_boundary
$this->alternative_boundary = md5(uniqid("dolibarr")); $this->alternative_boundary = md5(uniqid("dolibarr3"));
// 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';
...@@ -207,13 +207,13 @@ class CMailFile ...@@ -207,13 +207,13 @@ class CMailFile
// Define body in text_body // Define body in text_body
$text_body = $this->write_body($msg); $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 // Encode images
if ($this->atleastoneimage) if ($this->atleastoneimage)
{ {
$images_encoded = $this->write_images($this->images_encoded); $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 // Add attachments to text_encoded
...@@ -603,6 +603,8 @@ class CMailFile ...@@ -603,6 +603,8 @@ class CMailFile
$out.= "Content-Type: multipart/mixed; boundary=\"".$this->mixed_boundary."\"".$this->eol; $out.= "Content-Type: multipart/mixed; boundary=\"".$this->mixed_boundary."\"".$this->eol;
$out.= "Content-Transfer-Encoding: 8bit".$this->eol; $out.= "Content-Transfer-Encoding: 8bit".$this->eol;
if (! empty($conf->global->MAIN_MAIL_EMAIL_INLINE_IMAGES))
{
if ($this->atleastoneimage) if ($this->atleastoneimage)
{ {
$out.= "--" . $this->mixed_boundary . $this->eol; $out.= "--" . $this->mixed_boundary . $this->eol;
...@@ -617,6 +619,7 @@ class CMailFile ...@@ -617,6 +619,7 @@ class CMailFile
$out.= "Content-Type: multipart/alternative; boundary=\"".$this->alternative_boundary."\"".$this->eol; $out.= "Content-Type: multipart/alternative; boundary=\"".$this->alternative_boundary."\"".$this->eol;
$out.= $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 //$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); dol_syslog("CMailFile::write_smtpheaders smtp_header=\n".$out);
...@@ -666,12 +669,14 @@ class CMailFile ...@@ -666,12 +669,14 @@ class CMailFile
if ($this->msgishtml) 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; $out.= "Content-Type: text/html; charset=".$conf->file->character_set_client.$this->eol;
} }
else 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.= "Content-Type: text/plain; charset=".$conf->file->character_set_client.$this->eol;
} }
$out.= $this->eol; $out.= $this->eol;
...@@ -693,7 +698,7 @@ class CMailFile ...@@ -693,7 +698,7 @@ class CMailFile
$strContent = rtrim(wordwrap($strContent)); $strContent = rtrim(wordwrap($strContent));
$out.= $strContent.$this->eol; $out.= $strContent.$this->eol;
$out.= $this->eol; if (! empty($conf->global->MAIN_MAIL_EMAIL_INLINE_IMAGES)) $out.= $this->eol;
return $out; return $out;
} }
...@@ -759,7 +764,8 @@ class CMailFile ...@@ -759,7 +764,8 @@ class CMailFile
{ {
dol_syslog("CMailFile::write_images: i=$i"); 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-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-Disposition: inline; filename=\"".$img["name"]."\"".$this->eol; $out.= "Content-Disposition: inline; filename=\"".$img["name"]."\"".$this->eol;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment