Better management of the Dolibarr tracking id into email.

This will allow an imap scanner to link email
This commit is contained in:
Laurent Destailleur 2015-11-13 00:19:11 +01:00
parent 74a4006a84
commit 4065b3f1df
6 changed files with 28 additions and 16 deletions

View File

@ -152,7 +152,8 @@ if (($action == 'send' || $action == 'sendhtml') && ! GETPOST('addfile') && ! GE
$subject = $_POST['subject']; $subject = $_POST['subject'];
$body = $_POST['message']; $body = $_POST['message'];
$deliveryreceipt= $_POST["deliveryreceipt"]; $deliveryreceipt= $_POST["deliveryreceipt"];
$trackid = GETPOST('trackid');
//Check if we have to decode HTML //Check if we have to decode HTML
if (!empty($conf->global->FCKEDITOR_ENABLE_MAILING) && dol_textishtml(dol_html_entity_decode($body, ENT_COMPAT | ENT_HTML401))) { if (!empty($conf->global->FCKEDITOR_ENABLE_MAILING) && dol_textishtml(dol_html_entity_decode($body, ENT_COMPAT | ENT_HTML401))) {
$body=dol_html_entity_decode($body, ENT_COMPAT | ENT_HTML401); $body=dol_html_entity_decode($body, ENT_COMPAT | ENT_HTML401);
@ -202,7 +203,9 @@ if (($action == 'send' || $action == 'sendhtml') && ! GETPOST('addfile') && ! GE
$sendtoccc, $sendtoccc,
$deliveryreceipt, $deliveryreceipt,
$msgishtml, $msgishtml,
$errors_to $errors_to,
'',
$trackid
); );
$result=$mailfile->sendfile(); $result=$mailfile->sendfile();
@ -693,6 +696,7 @@ else
$formmail = new FormMail($db); $formmail = new FormMail($db);
$formmail->fromname = (isset($_POST['fromname'])?$_POST['fromname']:$conf->global->MAIN_MAIL_EMAIL_FROM); $formmail->fromname = (isset($_POST['fromname'])?$_POST['fromname']:$conf->global->MAIN_MAIL_EMAIL_FROM);
$formmail->frommail = (isset($_POST['frommail'])?$_POST['frommail']:$conf->global->MAIN_MAIL_EMAIL_FROM); $formmail->frommail = (isset($_POST['frommail'])?$_POST['frommail']:$conf->global->MAIN_MAIL_EMAIL_FROM);
$formmail->trackid='test';
$formmail->withfromreadonly=0; $formmail->withfromreadonly=0;
$formmail->withsubstit=0; $formmail->withsubstit=0;
$formmail->withfrom=1; $formmail->withfrom=1;

View File

@ -221,11 +221,12 @@ if (($action == 'send' || $action == 'relance') && ! $_POST['addfile'] && ! $_PO
$filename = $attachedfiles['names']; $filename = $attachedfiles['names'];
$mimetype = $attachedfiles['mimes']; $mimetype = $attachedfiles['mimes'];
$trackid = GETPOST('trackid','aZ'); $trackid = GETPOST('trackid','aZ09');
if($conf->dolimail->enabled) // Feature to push mail sent into Sent folder
if (! empty($conf->dolimail->enabled))
{ {
$mailfromid = explode ("#", $_POST['frommail'],3); $mailfromid = explode("#", $_POST['frommail'],3); // $_POST['frommail'] = 'aaa#Sent# <aaa@aaa.com>' // TODO Use a better way to define Sent dir.
if (count($mailfromid)==0) $from = $_POST['fromname'] . ' <' . $_POST['frommail'] .'>'; if (count($mailfromid)==0) $from = $_POST['fromname'] . ' <' . $_POST['frommail'] .'>';
else else
{ {
@ -243,7 +244,7 @@ if (($action == 'send' || $action == 'relance') && ! $_POST['addfile'] && ! $_PO
{ {
$folder=str_replace($ref, '', $mailboxconfig->folder_cache_key); $folder=str_replace($ref, '', $mailboxconfig->folder_cache_key);
if (!$folder) $folder = "Sent"; if (!$folder) $folder = "Sent"; // Default Sent folder
$mailboxconfig->mbox = imap_open($mailboxconfig->get_connector_url().$folder, $mailboxconfig->mailbox_imap_login, $mailboxconfig->mailbox_imap_password); $mailboxconfig->mbox = imap_open($mailboxconfig->get_connector_url().$folder, $mailboxconfig->mailbox_imap_login, $mailboxconfig->mailbox_imap_password);
if (FALSE === $mailboxconfig->mbox) if (FALSE === $mailboxconfig->mbox)
@ -276,17 +277,16 @@ if (($action == 'send' || $action == 'relance') && ! $_POST['addfile'] && ! $_PO
if ($result) if ($result)
{ {
$error=0; $error=0;
if($conf->dolimail->enabled) if (! empty($conf->dolimail->enabled))
{ {
$mid = (GETPOST('mid','int') ? GETPOST('mid','int') : 0); $mid = (GETPOST('mid','int') ? GETPOST('mid','int') : 0); // Original mail id is set ?
if ($mid) if ($mid)
{ {
// set imap flag answered if it is a answered mail // set imap flag answered if it is an answered mail
$dolimail=new DoliMail($db); $dolimail=new DoliMail($db);
$dolimail->id = $mid; $dolimail->id = $mid;
$res=$dolimail->set_prop($user, 'answered',1); $res=$dolimail->set_prop($user, 'answered',1);
} }
if ($imap==1) if ($imap==1)
{ {
// write mail to IMAP Server // write mail to IMAP Server

View File

@ -708,8 +708,10 @@ class CMailFile
$trackid = $this->trackid; $trackid = $this->trackid;
if ($trackid) if ($trackid)
{ {
$out.= 'Message-ID: <' . time() . '.phpmail-'.$trackid.'@' . $host . ">" . $this->eol2; // References is kept in response and Message-ID is returned into In-Reply-To:
$out.= 'references: <' . time() . '.phpmail-'.$trackid.'@' . $host . ">" . $this->eol2; $out.= 'Message-ID: <' . time() . '.phpmail-dolibarr-'.$trackid.'@' . $host . ">" . $this->eol2; // Uppercase seems replaced by phpmail
$out.= 'References: <' . time() . '.phpmail-dolibarr-'.$trackid.'@' . $host . ">" . $this->eol2;
$out.= 'X-Dolibarr-TRACKID: '.$trackid. $this->eol2;
} }
else else
{ {

View File

@ -1133,8 +1133,10 @@ class SMTPs
$trackid = $this->getTrackId(); $trackid = $this->getTrackId();
if ($trackid) if ($trackid)
{ {
$_header .= 'Message-ID: <' . time() . '.SMTPs-'.$trackid.'@' . $host . ">\r\n"; // References is kept in response and Message-ID is returned into In-Reply-To:
$_header .= 'references: <' . time() . '.SMTPs-'.$trackid.'@' . $host . ">\r\n"; $_header .= 'Message-ID: <' . time() . '.SMTPs-dolibarr-'.$trackid.'@' . $host . ">\r\n";
$_header .= 'References: <' . time() . '.SMTPs-dolibarr-'.$trackid.'@' . $host . ">\r\n";
$_header .= 'X-Dolibarr-TRACKID: ' . $trackid . "\r\n";
} }
else else
{ {

View File

@ -263,6 +263,10 @@ function GETPOST($paramname,$check='',$method=0,$filter=NULL,$options=NULL)
$out=trim($out); $out=trim($out);
if (preg_match('/[^a-z]+/i',$out)) $out=''; if (preg_match('/[^a-z]+/i',$out)) $out='';
break; break;
case 'aZ09':
$out=trim($out);
if (preg_match('/[^a-z0-9]+/i',$out)) $out='';
break;
case 'array': case 'array':
if (! is_array($out) || empty($out)) $out=array(); if (! is_array($out) || empty($out)) $out=array();
break; break;

View File

@ -232,7 +232,7 @@ body {
<?php } else { ?> <?php } else { ?>
background: rgb(<?php print $colorbackbody; ?>); background: rgb(<?php print $colorbackbody; ?>);
<?php } ?> <?php } ?>
color: #101010; color: rgb(<?php echo $colortext; ?>);
font-size: <?php print $fontsize ?>px; font-size: <?php print $fontsize ?>px;
font-family: <?php print $fontlist ?>; font-family: <?php print $fontlist ?>;
margin-top: 0; margin-top: 0;