Merge branch '11.0' into 12.0

This commit is contained in:
florian HENRY 2020-08-06 16:54:49 +02:00
commit 46cafcc445
2 changed files with 42 additions and 29 deletions

View File

@ -270,6 +270,26 @@ class CMailFile
} }
} }
// Add autocopy to (Note: Adding bcc for specific modules are also done from pages)
if (! empty($conf->global->MAIN_MAIL_AUTOCOPY_TO)) $addr_bcc.=($addr_bcc?', ':'').$conf->global->MAIN_MAIL_AUTOCOPY_TO;
$this->addr_to = $to;
$this->addr_cc = $addr_cc;
$this->addr_bcc = $addr_bcc;
$this->reply_to = $replyto;
$this->addr_from = $from;
$this->subject = $subject;
$this->errors_to = $errors_to;
$this->deliveryreceipt = $deliveryreceipt;
$this->trackid = $trackid;
if (!empty($conf->global->MAIN_MAIL_FORCE_SENDTO))
{
$this->addr_to = $conf->global->MAIN_MAIL_FORCE_SENDTO;
$this->addr_cc = '';
$this->addr_bcc = '';
}
// We set all data according to choosed sending method. // We set all data according to choosed sending method.
// We also set a value for ->msgid // We also set a value for ->msgid
if ($this->sendmode == 'mail') if ($this->sendmode == 'mail')
@ -330,16 +350,16 @@ class CMailFile
$smtps->setCharSet($conf->file->character_set_client); $smtps->setCharSet($conf->file->character_set_client);
// Encode subject if required. // Encode subject if required.
$subjecttouse = $subject; $subjecttouse = $this->subject;
if (!ascii_check($subjecttouse)) { if (!ascii_check($subjecttouse)) {
$subjecttouse = $this->encodetorfc2822($subjecttouse); $subjecttouse = $this->encodetorfc2822($subjecttouse);
} }
$smtps->setSubject($subjecttouse); $smtps->setSubject($subjecttouse);
$smtps->setTO($this->getValidAddress($to, 0, 1)); $smtps->setTO($this->getValidAddress($this->to, 0, 1));
$smtps->setFrom($this->getValidAddress($from, 0, 1)); $smtps->setFrom($this->getValidAddress($this->from, 0, 1));
$smtps->setTrackId($trackid); $smtps->setTrackId($this->trackid);
$smtps->setReplyTo($this->getValidAddress($replyto, 0, 1)); $smtps->setReplyTo($this->getValidAddress($this->replyto, 0, 1));
if (!empty($moreinheader)) $smtps->setMoreInHeader($moreinheader); if (!empty($moreinheader)) $smtps->setMoreInHeader($moreinheader);
@ -377,10 +397,10 @@ class CMailFile
} }
} }
$smtps->setCC($addr_cc); $smtps->setCC($this->addr_cc);
$smtps->setBCC($addr_bcc); $smtps->setBCC($this->addr_bcc);
$smtps->setErrorsTo($errors_to); $smtps->setErrorsTo($this->errors_to);
$smtps->setDeliveryReceipt($deliveryreceipt); $smtps->setDeliveryReceipt($this->deliveryreceipt);
$host = dol_getprefix('email'); $host = dol_getprefix('email');
$this->msgid = time().'.SMTPs-dolibarr-'.$trackid.'@'.$host; $this->msgid = time().'.SMTPs-dolibarr-'.$trackid.'@'.$host;
@ -405,8 +425,8 @@ class CMailFile
//$this->message = new Swift_SignedMessage(); //$this->message = new Swift_SignedMessage();
// Adding a trackid header to a message // Adding a trackid header to a message
$headers = $this->message->getHeaders(); $headers = $this->message->getHeaders();
$headers->addTextHeader('X-Dolibarr-TRACKID', $trackid.'@'.$host); $headers->addTextHeader('X-Dolibarr-TRACKID', $this->trackid.'@'.$host);
$this->msgid = time().'.swiftmailer-dolibarr-'.$trackid.'@'.$host; $this->msgid = time().'.swiftmailer-dolibarr-'.$this->trackid.'@'.$host;
$headerID = $this->msgid; $headerID = $this->msgid;
$msgid = $headers->get('Message-ID'); $msgid = $headers->get('Message-ID');
$msgid->setId($headerID); $msgid->setId($headerID);
@ -415,33 +435,33 @@ class CMailFile
// Give the message a subject // Give the message a subject
try { try {
$result = $this->message->setSubject($subject); $result = $this->message->setSubject($this->subject);
} catch (Exception $e) { } catch (Exception $e) {
$this->errors[] = $e->getMessage(); $this->errors[] = $e->getMessage();
} }
// Set the From address with an associative array // Set the From address with an associative array
//$this->message->setFrom(array('john@doe.com' => 'John Doe')); //$this->message->setFrom(array('john@doe.com' => 'John Doe'));
if (!empty($from)) { if (! empty($this->addr_from)) {
try { try {
$result = $this->message->setFrom($this->getArrayAddress($from)); $result = $this->message->setFrom($this->getArrayAddress($this->addr_from));
} catch (Exception $e) { } catch (Exception $e) {
$this->errors[] = $e->getMessage(); $this->errors[] = $e->getMessage();
} }
} }
// Set the To addresses with an associative array // Set the To addresses with an associative array
if (!empty($to)) { if (! empty($this->addr_to)) {
try { try {
$result = $this->message->setTo($this->getArrayAddress($to)); $result = $this->message->setTo($this->getArrayAddress($this->addr_to));
} catch (Exception $e) { } catch (Exception $e) {
$this->errors[] = $e->getMessage(); $this->errors[] = $e->getMessage();
} }
} }
if (!empty($replyto)) { if (! empty($this->reply_to)) {
try { try {
$result = $this->message->SetReplyTo($this->getArrayAddress($replyto)); $result = $this->message->SetReplyTo($this->getArrayAddress($this->reply_to));
} catch (Exception $e) { } catch (Exception $e) {
$this->errors[] = $e->getMessage(); $this->errors[] = $e->getMessage();
} }
@ -495,10 +515,10 @@ class CMailFile
} }
} }
if (!empty($addr_cc)) $this->message->setCc($this->getArrayAddress($addr_cc)); if (! empty($this->addr_cc)) $this->message->setCc($this->getArrayAddress($this->addr_cc));
if (!empty($addr_bcc)) $this->message->setBcc($this->getArrayAddress($addr_bcc)); if (! empty($this->addr_bcc)) $this->message->setBcc($this->getArrayAddress($this->addr_bcc));
//if (! empty($errors_to)) $this->message->setErrorsTo($this->getArrayAddress($errors_to); //if (! empty($errors_to)) $this->message->setErrorsTo($this->getArrayAddress($errors_to);
if (isset($deliveryreceipt) && $deliveryreceipt == 1) $this->message->setReadReceiptTo($this->getArrayAddress($from)); if (isset($this->deliveryreceipt) && $this->deliveryreceipt == 1) $this->message->setReadReceiptTo($this->getArrayAddress($this->addr_from));
} }
else else
{ {
@ -617,13 +637,6 @@ class CMailFile
$keyforstarttls = 'MAIN_MAIL_EMAIL_STARTTLS_EMAILING'; $keyforstarttls = 'MAIN_MAIL_EMAIL_STARTTLS_EMAILING';
} }
if (!empty($conf->global->MAIN_MAIL_FORCE_SENDTO))
{
$this->addr_to = $conf->global->MAIN_MAIL_FORCE_SENDTO;
$this->addr_cc = '';
$this->addr_bcc = '';
}
// Action according to choosed sending method // Action according to choosed sending method
if ($this->sendmode == 'mail') if ($this->sendmode == 'mail')
{ {

View File

@ -241,7 +241,7 @@ function dolNumberToWord($numero, $langs, $numorcurrency = 'number')
$entexto .= hundreds2text($c, $d, $u); $entexto .= hundreds2text($c, $d, $u);
if (!$cdm && !$ddm && !$udm && !$c && !$d && !$u && $number > 1000000) if (!$cdm && !$ddm && !$udm && !$c && !$d && !$u && $number > 1000000)
$entexto .= " DE"; $entexto .= " DE";
$entexto .= " PESOS ".$parte_decimal." / 100 M.N."; $entexto .= " PESOS ".$parte_decimal." / 100 M.N.";
} }
return $entexto; return $entexto;
} }