Fix substitution of __EMAIL__

This commit is contained in:
Laurent Destailleur 2017-08-28 12:49:57 +02:00
parent 73a799b0ce
commit 075a138e14
2 changed files with 16 additions and 14 deletions

View File

@ -61,7 +61,7 @@ $object->substitutionarray['__(AnyTranslationKey)__']=$langs->trans("Translation
$object->substitutionarrayfortest=array( $object->substitutionarrayfortest=array(
'__ID__' => 'TESTIdRecord', '__ID__' => 'TESTIdRecord',
'__EMAIL__' => 'TESTEMail', //'__EMAIL__' => 'TESTEMail', // Done into "send" action
'__LASTNAME__' => 'TESTLastname', '__LASTNAME__' => 'TESTLastname',
'__FIRSTNAME__' => 'TESTFirstname', '__FIRSTNAME__' => 'TESTFirstname',
'__MAILTOEMAIL__' => 'TESTMailtoEmail', '__MAILTOEMAIL__' => 'TESTMailtoEmail',
@ -409,6 +409,8 @@ if (empty($reshook))
$msgishtml=-1; // Inconnu par defaut $msgishtml=-1; // Inconnu par defaut
if (preg_match('/[\s\t]*<html>/i',$object->body)) $msgishtml=1; if (preg_match('/[\s\t]*<html>/i',$object->body)) $msgishtml=1;
$object->substitutionarrayfortest['__EMAIL__'] = $object->sendto; // other are set at begin of page
// Pratique les substitutions sur le sujet et message // Pratique les substitutions sur le sujet et message
$tmpsujet=make_substitutions($object->sujet,$object->substitutionarrayfortest); $tmpsujet=make_substitutions($object->sujet,$object->substitutionarrayfortest);
$tmpbody=make_substitutions($object->body,$object->substitutionarrayfortest); $tmpbody=make_substitutions($object->body,$object->substitutionarrayfortest);

View File

@ -39,7 +39,7 @@ class CMailFile
public $sendcontext; public $sendcontext;
public $sendmode; public $sendmode;
public $sendsetup; public $sendsetup;
var $subject; // Topic: Subject of email var $subject; // Topic: Subject of email
var $addr_from; // From: Label and EMail of sender (must include '<>'). For example '<myemail@example.com>' or 'John Doe <myemail@example.com>' or '<myemail+trackingid@example.com>'). Note that with gmail smtps, value here is forced by google to account (but not the reply-to). var $addr_from; // From: Label and EMail of sender (must include '<>'). For example '<myemail@example.com>' or 'John Doe <myemail@example.com>' or '<myemail+trackingid@example.com>'). Note that with gmail smtps, value here is forced by google to account (but not the reply-to).
// Sender: Who send the email ("Sender" has sent emails on behalf of "From"). // Sender: Who send the email ("Sender" has sent emails on behalf of "From").
@ -115,14 +115,14 @@ class CMailFile
global $conf, $dolibarr_main_data_root; global $conf, $dolibarr_main_data_root;
$this->sendcontext = $sendcontext; $this->sendcontext = $sendcontext;
$this->sendmode = ''; $this->sendmode = '';
if ($this->sendcontext == 'emailing') $this->sendmode = $conf->global->EMAILING_MAIL_SENDMODE; if ($this->sendcontext == 'emailing') $this->sendmode = $conf->global->EMAILING_MAIL_SENDMODE;
if (empty($this->sendmode)) $this->sendmode=$conf->global->MAIN_MAIL_SENDMODE; if (empty($this->sendmode)) $this->sendmode=$conf->global->MAIN_MAIL_SENDMODE;
if (empty($this->sendmode)) $this->sendmode='mail'; if (empty($this->sendmode)) $this->sendmode='mail';
$this->sendsetup = array(); $this->sendsetup = array();
// We define end of line (RFC 821). // We define end of line (RFC 821).
$this->eol="\r\n"; $this->eol="\r\n";
@ -157,7 +157,7 @@ class CMailFile
{ {
dol_syslog("CMailFile::CMailfile: Try to send an email with empty body"); dol_syslog("CMailFile::CMailfile: Try to send an email with empty body");
$msg='.'; // Avoid empty message (with empty message conten show a multipart structure) $msg='.'; // Avoid empty message (with empty message conten show a multipart structure)
} }
// Detect if message is HTML (use fast method) // Detect if message is HTML (use fast method)
if ($msgishtml == -1) if ($msgishtml == -1)
@ -178,7 +178,7 @@ class CMailFile
//$urlwithroot=DOL_MAIN_URL_ROOT; // This is to use same domain name than current //$urlwithroot=DOL_MAIN_URL_ROOT; // This is to use same domain name than current
// Replace relative /viewimage to absolute path // Replace relative /viewimage to absolute path
$msg = preg_replace('/src="'.preg_quote(DOL_URL_ROOT,'/').'\/viewimage\.php/', 'src="'.$urlwithroot.'/viewimage.php', $msg, -1, $nbrep); $msg = preg_replace('/src="'.preg_quote(DOL_URL_ROOT,'/').'\/viewimage\.php/ims', 'src="'.$urlwithroot.'/viewimage.php', $msg, -1, $nbrep);
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.
@ -240,7 +240,7 @@ class CMailFile
$this->addr_bcc = $addr_bcc; $this->addr_bcc = $addr_bcc;
$this->deliveryreceipt = $deliveryreceipt; $this->deliveryreceipt = $deliveryreceipt;
$this->trackid = $trackid; $this->trackid = $trackid;
$smtp_headers = $this->write_smtpheaders(); $smtp_headers = $this->write_smtpheaders();
if (! empty($moreinheader)) $smtp_headers.=$moreinheader; // $moreinheader contains the \r\n if (! empty($moreinheader)) $smtp_headers.=$moreinheader; // $moreinheader contains the \r\n
@ -349,7 +349,7 @@ class CMailFile
$this->phpmailer->SetReplyTo($this->getValidAddress($from,0,1)); // Set property with this->phpmailer->setReplyTo after constructor if you want to use another value than the From $this->phpmailer->SetReplyTo($this->getValidAddress($from,0,1)); // Set property with this->phpmailer->setReplyTo after constructor if you want to use another value than the From
// TODO Add trackid into smtp header // TODO Add trackid into smtp header
// TODO if (! empty($moreinheader)) ... // TODO if (! empty($moreinheader)) ...
if (! empty($this->html)) if (! empty($this->html))
{ {
if (!empty($css)) if (!empty($css))
@ -676,7 +676,7 @@ class CMailFile
if ($res) if ($res)
{ {
if (! empty($conf->global->MAIN_MAIL_DEBUG)) $this->smtps->setDebug(true); if (! empty($conf->global->MAIN_MAIL_DEBUG)) $this->smtps->setDebug(true);
$result=$this->smtps->sendMsg(); $result=$this->smtps->sendMsg();
//print $result; //print $result;
@ -1036,7 +1036,7 @@ class CMailFile
$out.= $this->eol; $out.= $this->eol;
$out.= "--" . $this->related_boundary . $this->eol; $out.= "--" . $this->related_boundary . $this->eol;
} }
if (! $this->atleastoneimage && $strContentAltText && ! empty($conf->global->MAIN_MAIL_USE_MULTI_PART)) // Add plain text message part before html part if (! $this->atleastoneimage && $strContentAltText && ! empty($conf->global->MAIN_MAIL_USE_MULTI_PART)) // Add plain text message part before html part
{ {
$out.= "Content-Type: multipart/alternative; boundary=\"".$this->alternative_boundary."\"".$this->eol; $out.= "Content-Type: multipart/alternative; boundary=\"".$this->alternative_boundary."\"".$this->eol;
@ -1046,7 +1046,7 @@ class CMailFile
$out.= $this->eol.$strContentAltText.$this->eol; $out.= $this->eol.$strContentAltText.$this->eol;
$out.= "--" . $this->alternative_boundary . $this->eol; $out.= "--" . $this->alternative_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;
$out.= $this->eol.$strContent.$this->eol; $out.= $this->eol.$strContent.$this->eol;
@ -1365,7 +1365,7 @@ class CMailFile
if ($email) if ($email)
{ {
$i++; $i++;
$newemail=''; $newemail='';
if ($format == 4) if ($format == 4)
{ {