Skip to content
Snippets Groups Projects
Commit 351c416e authored by Laurent Destailleur's avatar Laurent Destailleur Committed by GitHub
Browse files

Merge pull request #6265 from hregis/4.0_bug

Fix: avoid errors if constants values not exists
parents f408c886 5898d276
No related branches found
No related tags found
No related merge requests found
...@@ -153,7 +153,7 @@ class CMailFile ...@@ -153,7 +153,7 @@ class CMailFile
} }
if (! empty($conf->global->MAIN_MAIL_FORCE_CONTENT_TYPE_TO_HTML)) $this->msgishtml=1; // To force to send everything with content type html. if (! empty($conf->global->MAIN_MAIL_FORCE_CONTENT_TYPE_TO_HTML)) $this->msgishtml=1; // To force to send everything with content type html.
// Detect images // Detect images
if ($this->msgishtml) if ($this->msgishtml)
{ {
...@@ -210,7 +210,7 @@ class CMailFile ...@@ -210,7 +210,7 @@ class CMailFile
$this->trackid = $trackid; $this->trackid = $trackid;
$smtp_headers = $this->write_smtpheaders(); $smtp_headers = $this->write_smtpheaders();
if (! empty($moreinheader)) $smtp_headers.=$moreinheader; if (! empty($moreinheader)) $smtp_headers.=$moreinheader;
// Define mime_headers // Define mime_headers
$mime_headers = $this->write_mimeheaders($filename_list, $mimefilename_list); $mime_headers = $this->write_mimeheaders($filename_list, $mimefilename_list);
...@@ -270,7 +270,7 @@ class CMailFile ...@@ -270,7 +270,7 @@ class CMailFile
$smtps->setFrom($this->getValidAddress($from,0,1)); $smtps->setFrom($this->getValidAddress($from,0,1));
$smtps->setTrackId($trackid); $smtps->setTrackId($trackid);
$smtps->setReplyTo($this->getValidAddress($from,0,1)); // Set property with this->smtps->setReplyTo after constructor if you want to use another value than the From $smtps->setReplyTo($this->getValidAddress($from,0,1)); // Set property with this->smtps->setReplyTo after constructor if you want to use another value than the From
if (! empty($this->html)) if (! empty($this->html))
{ {
if (!empty($css)) if (!empty($css))
...@@ -473,16 +473,16 @@ class CMailFile ...@@ -473,16 +473,16 @@ class CMailFile
'maildao' 'maildao'
)); ));
$reshook = $hookmanager->executeHooks('doactions', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks $reshook = $hookmanager->executeHooks('doactions', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks
if (! empty($reshook)) if (! empty($reshook))
{ {
$this->error = "Error in hook maildao doactions " . $reshook; $this->error = "Error in hook maildao doactions " . $reshook;
dol_syslog("CMailFile::sendfile: mail end error=" . $this->error, LOG_ERR); dol_syslog("CMailFile::sendfile: mail end error=" . $this->error, LOG_ERR);
return $reshook; return $reshook;
} }
// Check number of recipient is lower or equal than MAIL_MAX_NB_OF_RECIPIENTS_IN_SAME_EMAIL // Check number of recipient is lower or equal than MAIL_MAX_NB_OF_RECIPIENTS_IN_SAME_EMAIL
if (empty($conf->global->MAIL_MAX_NB_OF_RECIPIENTS_IN_SAME_EMAIL)) $conf->global->MAIL_MAX_NB_OF_RECIPIENTS_IN_SAME_EMAIL=10; if (empty($conf->global->MAIL_MAX_NB_OF_RECIPIENTS_TO_IN_SAME_EMAIL)) $conf->global->MAIL_MAX_NB_OF_RECIPIENTS_TO_IN_SAME_EMAIL=6;
$tmparray1 = explode(',', $this->addr_to); $tmparray1 = explode(',', $this->addr_to);
if (count($tmparray1) > $conf->global->MAIL_MAX_NB_OF_RECIPIENTS_TO_IN_SAME_EMAIL) if (count($tmparray1) > $conf->global->MAIL_MAX_NB_OF_RECIPIENTS_TO_IN_SAME_EMAIL)
{ {
...@@ -490,6 +490,7 @@ class CMailFile ...@@ -490,6 +490,7 @@ class CMailFile
dol_syslog("CMailFile::sendfile: mail end error=" . $this->error, LOG_WARNING); dol_syslog("CMailFile::sendfile: mail end error=" . $this->error, LOG_WARNING);
return false; return false;
} }
if (empty($conf->global->MAIL_MAX_NB_OF_RECIPIENTS_CC_IN_SAME_EMAIL)) $conf->global->MAIL_MAX_NB_OF_RECIPIENTS_CC_IN_SAME_EMAIL=2;
$tmparray2 = explode(',', $this->addr_cc); $tmparray2 = explode(',', $this->addr_cc);
if (count($tmparray2) > $conf->global->MAIL_MAX_NB_OF_RECIPIENTS_CC_IN_SAME_EMAIL) if (count($tmparray2) > $conf->global->MAIL_MAX_NB_OF_RECIPIENTS_CC_IN_SAME_EMAIL)
{ {
...@@ -497,6 +498,7 @@ class CMailFile ...@@ -497,6 +498,7 @@ class CMailFile
dol_syslog("CMailFile::sendfile: mail end error=" . $this->error, LOG_WARNING); dol_syslog("CMailFile::sendfile: mail end error=" . $this->error, LOG_WARNING);
return false; return false;
} }
if (empty($conf->global->MAIL_MAX_NB_OF_RECIPIENTS_BCC_IN_SAME_EMAIL)) $conf->global->MAIL_MAX_NB_OF_RECIPIENTS_BCC_IN_SAME_EMAIL=2;
$tmparray3 = explode(',', $this->addr_bcc); $tmparray3 = explode(',', $this->addr_bcc);
if (count($tmparray3) > $conf->global->MAIL_MAX_NB_OF_RECIPIENTS_BCC_IN_SAME_EMAIL) if (count($tmparray3) > $conf->global->MAIL_MAX_NB_OF_RECIPIENTS_BCC_IN_SAME_EMAIL)
{ {
...@@ -504,14 +506,14 @@ class CMailFile ...@@ -504,14 +506,14 @@ class CMailFile
dol_syslog("CMailFile::sendfile: mail end error=" . $this->error, LOG_WARNING); dol_syslog("CMailFile::sendfile: mail end error=" . $this->error, LOG_WARNING);
return false; return false;
} }
if (empty($conf->global->MAIL_MAX_NB_OF_RECIPIENTS_IN_SAME_EMAIL)) $conf->global->MAIL_MAX_NB_OF_RECIPIENTS_IN_SAME_EMAIL=10;
if ((count($tmparray1)+count($tmparray2)+count($tmparray3)) > $conf->global->MAIL_MAX_NB_OF_RECIPIENTS_IN_SAME_EMAIL) if ((count($tmparray1)+count($tmparray2)+count($tmparray3)) > $conf->global->MAIL_MAX_NB_OF_RECIPIENTS_IN_SAME_EMAIL)
{ {
$this->error = 'Too much recipients in to:, cc:, bcc:'; $this->error = 'Too much recipients in to:, cc:, bcc:';
dol_syslog("CMailFile::sendfile: mail end error=" . $this->error, LOG_WARNING); dol_syslog("CMailFile::sendfile: mail end error=" . $this->error, LOG_WARNING);
return false; return false;
} }
// Action according to choosed sending method // Action according to choosed sending method
if ($conf->global->MAIN_MAIL_SENDMODE == 'mail') if ($conf->global->MAIN_MAIL_SENDMODE == 'mail')
{ {
...@@ -553,7 +555,7 @@ class CMailFile ...@@ -553,7 +555,7 @@ class CMailFile
$bounce .= ($bounce?' ':'').'-ba'; $bounce .= ($bounce?' ':'').'-ba';
} }
dol_syslog("CMailFile::sendfile: mail start HOST=".ini_get('SMTP').", PORT=".ini_get('smtp_port').", additionnal_parameters=".$bounce, LOG_DEBUG); dol_syslog("CMailFile::sendfile: mail start HOST=".ini_get('SMTP').", PORT=".ini_get('smtp_port').", additionnal_parameters=".$bounce, LOG_DEBUG);
$this->message=stripslashes($this->message); $this->message=stripslashes($this->message);
if (! empty($conf->global->MAIN_MAIL_DEBUG)) $this->dump_mail(); if (! empty($conf->global->MAIN_MAIL_DEBUG)) $this->dump_mail();
...@@ -873,7 +875,7 @@ class CMailFile ...@@ -873,7 +875,7 @@ class CMailFile
// Receiver // Receiver
if (isset($this->addr_cc) && $this->addr_cc) $out.= "Cc: ".$this->getValidAddress($this->addr_cc,2).$this->eol2; if (isset($this->addr_cc) && $this->addr_cc) $out.= "Cc: ".$this->getValidAddress($this->addr_cc,2).$this->eol2;
if (isset($this->addr_bcc) && $this->addr_bcc) $out.= "Bcc: ".$this->getValidAddress($this->addr_bcc,2).$this->eol2; // Question: bcc must not be into header, only into SMTP command "RCPT TO". Does php mail support this ? if (isset($this->addr_bcc) && $this->addr_bcc) $out.= "Bcc: ".$this->getValidAddress($this->addr_bcc,2).$this->eol2; // Question: bcc must not be into header, only into SMTP command "RCPT TO". Does php mail support this ?
// Delivery receipt // Delivery receipt
if (isset($this->deliveryreceipt) && $this->deliveryreceipt == 1) $out.= "Disposition-Notification-To: ".$this->getValidAddress($this->addr_from,2).$this->eol2; if (isset($this->deliveryreceipt) && $this->deliveryreceipt == 1) $out.= "Disposition-Notification-To: ".$this->getValidAddress($this->addr_from,2).$this->eol2;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment