Fix: Fixed a very old bug making file attachment fails with some emails readers when using "mail php function".
This commit is contained in:
parent
bcb9b8d8a8
commit
0498c6202f
@ -43,6 +43,9 @@ For users:
|
|||||||
- Fix: Database name can contains "-" characters.
|
- Fix: Database name can contains "-" characters.
|
||||||
- Fix: In coloring negative amounts.
|
- Fix: In coloring negative amounts.
|
||||||
- Fix: Date input use date format of user and not dd/mm/yyyy format.
|
- Fix: Date input use date format of user and not dd/mm/yyyy format.
|
||||||
|
- Fix: Fixed a very old bug making file attachment fails with some emails
|
||||||
|
readers when using "mail php function".
|
||||||
|
|
||||||
|
|
||||||
For translators:
|
For translators:
|
||||||
- New: Update and complete slovenian language sl_SL.
|
- New: Update and complete slovenian language sl_SL.
|
||||||
|
|||||||
@ -475,7 +475,8 @@ class CMailFile
|
|||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Ecrit le mail dans un fichier. Utilisation pour le debuggage.
|
* Write content of a SMTP request into a dump file (mode = all)
|
||||||
|
* Used for debugging.
|
||||||
*/
|
*/
|
||||||
function dump_mail()
|
function dump_mail()
|
||||||
{
|
{
|
||||||
@ -502,8 +503,64 @@ class CMailFile
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Correct an uncomplete html string
|
||||||
|
*
|
||||||
|
* @param $msg
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
function checkIfHTML($msg)
|
||||||
|
{
|
||||||
|
if (!preg_match('/^[\s\t]*<html/i',$msg))
|
||||||
|
{
|
||||||
|
$out = "<html><head><title></title>";
|
||||||
|
if (!empty($this->styleCSS)) $out.= $this->styleCSS;
|
||||||
|
$out.= "</head><body";
|
||||||
|
if (!empty($this->bodyCSS)) $out.= $this->bodyCSS;
|
||||||
|
$out.= ">";
|
||||||
|
$out.= $msg;
|
||||||
|
$out.= "</body></html>";
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$out = $msg;
|
||||||
|
}
|
||||||
|
|
||||||
|
return $out;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Build a css style (mode = all)
|
||||||
|
*
|
||||||
|
* @return css
|
||||||
|
*/
|
||||||
|
function buildCSS()
|
||||||
|
{
|
||||||
|
if (! empty($this->css))
|
||||||
|
{
|
||||||
|
// Style CSS
|
||||||
|
$this->styleCSS = '<style type="text/css">';
|
||||||
|
$this->styleCSS.= 'body {';
|
||||||
|
|
||||||
|
if ($this->css['bgcolor'])
|
||||||
|
{
|
||||||
|
$this->styleCSS.= ' background-color: '.$this->css['bgcolor'].';';
|
||||||
|
$this->bodyCSS.= ' BGCOLOR="'.$this->css['bgcolor'].'"';
|
||||||
|
}
|
||||||
|
if ($this->css['bgimage'])
|
||||||
|
{
|
||||||
|
// TODO recuperer cid
|
||||||
|
$this->styleCSS.= ' background-image: url("cid:'.$this->css['bgimage_cid'].'");';
|
||||||
|
}
|
||||||
|
$this->styleCSS.= '}';
|
||||||
|
$this->styleCSS.= '</style>';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create SMTP headers
|
* Create SMTP headers (mode = 'mail')
|
||||||
*
|
*
|
||||||
* @return smtp headers
|
* @return smtp headers
|
||||||
*/
|
*/
|
||||||
@ -583,12 +640,12 @@ class CMailFile
|
|||||||
if ($this->msgishtml)
|
if ($this->msgishtml)
|
||||||
{
|
{
|
||||||
$out.= "--" . $this->mime_boundary . $this->eol;
|
$out.= "--" . $this->mime_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.= "--" . $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;
|
||||||
|
|
||||||
@ -605,67 +662,14 @@ class CMailFile
|
|||||||
// Make RFC821 Compliant, replace bare linefeeds
|
// Make RFC821 Compliant, replace bare linefeeds
|
||||||
$strContent = preg_replace("/(?<!\r)\n/si", "\r\n", $strContent );
|
$strContent = preg_replace("/(?<!\r)\n/si", "\r\n", $strContent );
|
||||||
|
|
||||||
$strContent = rtrim(wordwrap($strContent));
|
//$strContent = rtrim(wordwrap($strContent));
|
||||||
|
$strContent = rtrim(chunk_split($strContent));
|
||||||
|
|
||||||
$out.=$strContent.$this->eol;
|
$out.=$strContent.$this->eol;
|
||||||
|
|
||||||
return $out;
|
return $out;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Correct an uncomplete html string
|
|
||||||
*
|
|
||||||
* @param $msg
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
function checkIfHTML($msg)
|
|
||||||
{
|
|
||||||
if (!preg_match('/^[\s\t]*<html/i',$msg))
|
|
||||||
{
|
|
||||||
$out = "<html><head><title></title>";
|
|
||||||
if (!empty($this->styleCSS)) $out.= $this->styleCSS;
|
|
||||||
$out.= "</head><body";
|
|
||||||
if (!empty($this->bodyCSS)) $out.= $this->bodyCSS;
|
|
||||||
$out.= ">";
|
|
||||||
$out.= $msg;
|
|
||||||
$out.= "</body></html>";
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
$out = $msg;
|
|
||||||
}
|
|
||||||
|
|
||||||
return $out;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Build a css style
|
|
||||||
*
|
|
||||||
* @return css
|
|
||||||
*/
|
|
||||||
function buildCSS()
|
|
||||||
{
|
|
||||||
if (! empty($this->css))
|
|
||||||
{
|
|
||||||
// Style CSS
|
|
||||||
$this->styleCSS = '<style type="text/css">';
|
|
||||||
$this->styleCSS.= 'body {';
|
|
||||||
|
|
||||||
if ($this->css['bgcolor'])
|
|
||||||
{
|
|
||||||
$this->styleCSS.= ' background-color: '.$this->css['bgcolor'].';';
|
|
||||||
$this->bodyCSS.= ' BGCOLOR="'.$this->css['bgcolor'].'"';
|
|
||||||
}
|
|
||||||
if ($this->css['bgimage'])
|
|
||||||
{
|
|
||||||
// TODO recuperer cid
|
|
||||||
$this->styleCSS.= ' background-image: url("cid:'.$this->css['bgimage_cid'].'");';
|
|
||||||
}
|
|
||||||
$this->styleCSS.= '}';
|
|
||||||
$this->styleCSS.= '</style>';
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Permet d'attacher un fichier (mode = 'mail')
|
* Permet d'attacher un fichier (mode = 'mail')
|
||||||
*
|
*
|
||||||
@ -691,10 +695,10 @@ class CMailFile
|
|||||||
if (! $mimetype_list[$i]) { $mimetype_list[$i] = "application/octet-stream"; }
|
if (! $mimetype_list[$i]) { $mimetype_list[$i] = "application/octet-stream"; }
|
||||||
|
|
||||||
$out.= "--" . $this->mime_boundary . $this->eol;
|
$out.= "--" . $this->mime_boundary . $this->eol;
|
||||||
|
$out.= "Content-Disposition: attachment; filename=\"".$filename_list[$i]."\"".$this->eol;
|
||||||
$out.= "Content-Type: " . $mimetype_list[$i] . "; name=\"".$filename_list[$i]."\"".$this->eol;
|
$out.= "Content-Type: " . $mimetype_list[$i] . "; name=\"".$filename_list[$i]."\"".$this->eol;
|
||||||
$out.= "Content-Transfer-Encoding: base64".$this->eol;
|
$out.= "Content-Transfer-Encoding: base64".$this->eol;
|
||||||
$out.= "Content-Disposition: attachment; filename=\"".$filename_list[$i]."\"".$this->eol;
|
$out.= "Content-Description: File Attachment".$this->eol;
|
||||||
$out.= "Content-Description: \""."File Attachment"."\"".$this->eol;
|
|
||||||
$out.= $this->eol;
|
$out.= $this->eol;
|
||||||
$out.= $encoded;
|
$out.= $encoded;
|
||||||
$out.= $this->eol;
|
$out.= $this->eol;
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user