mirror of
https://github.com/Dolibarr/dolibarr.git
synced 2025-02-20 13:46:52 +01:00
NEW Support Reply-To tracking in emails sending (tickets only for the
moment)
This commit is contained in:
parent
f95ccd91e8
commit
5fadea4d0d
|
|
@ -81,19 +81,20 @@ class CMailFile
|
|||
*/
|
||||
public $errors = array();
|
||||
|
||||
public $smtps; // Contains SMTPs object (if this method is used)
|
||||
public $phpmailer; // Contains PHPMailer object (if this method is used)
|
||||
|
||||
/**
|
||||
* @var SMTPS (if this method is used)
|
||||
*/
|
||||
public $smtps;
|
||||
/**
|
||||
* @var Swift_Mailer (if the method is used)
|
||||
*/
|
||||
public $mailer;
|
||||
|
||||
/**
|
||||
* @var Swift_SmtpTransport
|
||||
*/
|
||||
public $transport;
|
||||
|
||||
/**
|
||||
* @var Swift_Mailer
|
||||
*/
|
||||
public $mailer;
|
||||
|
||||
/**
|
||||
* @var Swift_Plugins_Loggers_ArrayLogger
|
||||
*/
|
||||
|
|
@ -108,9 +109,13 @@ class CMailFile
|
|||
//! Defined background directly in body tag
|
||||
public $bodyCSS;
|
||||
|
||||
/**
|
||||
* @var string Message-ID of the email to send (generated)
|
||||
*/
|
||||
public $msgid;
|
||||
public $headers;
|
||||
public $message;
|
||||
|
||||
/**
|
||||
* @var array fullfilenames list (full path of filename on file system)
|
||||
*/
|
||||
|
|
@ -579,12 +584,15 @@ class CMailFile
|
|||
//$this->message = new Swift_SignedMessage();
|
||||
// Adding a trackid header to a message
|
||||
$headers = $this->message->getHeaders();
|
||||
|
||||
$headers->addTextHeader('X-Dolibarr-TRACKID', $this->trackid.'@'.$host);
|
||||
$this->msgid = time().'.swiftmailer-dolibarr-'.$this->trackid.'@'.$host;
|
||||
$headerID = $this->msgid;
|
||||
$msgid = $headers->get('Message-ID');
|
||||
$msgid->setId($headerID);
|
||||
$headers->addIdHeader('References', $headerID);
|
||||
|
||||
// Add 'References:' header
|
||||
//$headers->addIdHeader('References', $headerID);
|
||||
|
||||
if (!empty($moreinheader)) {
|
||||
$moreinheaderarray = preg_split('/[\r\n]+/', $moreinheader);
|
||||
|
|
@ -727,7 +735,6 @@ class CMailFile
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Send mail that was prepared by constructor.
|
||||
*
|
||||
|
|
@ -1536,7 +1543,7 @@ class CMailFile
|
|||
// References is kept in response and Message-ID is returned into In-Reply-To:
|
||||
$this->msgid = time().'.phpmail-dolibarr-'.$trackid.'@'.$host;
|
||||
$out .= 'Message-ID: <'.$this->msgid.">".$this->eol2; // Uppercase seems replaced by phpmail
|
||||
$out .= 'References: <'.$this->msgid.">".$this->eol2;
|
||||
//$out .= 'References: <'.$this->msgid.">".$this->eol2;
|
||||
$out .= 'X-Dolibarr-TRACKID: '.$trackid.'@'.$host.$this->eol2;
|
||||
} else {
|
||||
$this->msgid = time().'.phpmail@'.$host;
|
||||
|
|
|
|||
|
|
@ -651,12 +651,9 @@ class SMTPs
|
|||
*/
|
||||
public function sendMsg()
|
||||
{
|
||||
global $conf;
|
||||
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/lib/geturl.lib.php';
|
||||
/**
|
||||
* Default return value
|
||||
*/
|
||||
|
||||
// Default return value
|
||||
$_retVal = false;
|
||||
|
||||
// Connect to Server
|
||||
|
|
@ -1451,10 +1448,10 @@ class SMTPs
|
|||
|
||||
$trackid = $this->getTrackId();
|
||||
if ($trackid) {
|
||||
// References is kept in response and Message-ID is returned into In-Reply-To:
|
||||
$_header .= 'Message-ID: <'.time().'.SMTPs-dolibarr-'.$trackid.'@'.$host.">\r\n";
|
||||
$_header .= 'References: <'.time().'.SMTPs-dolibarr-'.$trackid.'@'.$host.">\r\n";
|
||||
$_header .= 'X-Dolibarr-TRACKID: '.$trackid.'@'.$host."\r\n";
|
||||
// References and In-Reply-To: will be set by caller
|
||||
//$_header .= 'References: <'.time().'.SMTPs-dolibarr-'.$trackid.'@'.$host.">\r\n";
|
||||
} else {
|
||||
$_header .= 'Message-ID: <'.time().'.SMTPs@'.$host.">\r\n";
|
||||
}
|
||||
|
|
@ -1465,10 +1462,6 @@ class SMTPs
|
|||
$_header .= $this->getMoreInHeader(); // Value must include the "\r\n";
|
||||
}
|
||||
|
||||
//$_header .=
|
||||
// 'Read-Receipt-To: ' . $this->getFrom( 'org' ) . "\r\n"
|
||||
// 'Return-Receipt-To: ' . $this->getFrom( 'org' ) . "\r\n";
|
||||
|
||||
if ($this->getSensitivity()) {
|
||||
$_header .= 'Sensitivity: '.$this->getSensitivity()."\r\n";
|
||||
}
|
||||
|
|
@ -1493,6 +1486,7 @@ class SMTPs
|
|||
$_header .= 'X-Dolibarr-Option: '.($conf->global->MAIN_MAIL_USE_MULTI_PART ? 'MAIN_MAIL_USE_MULTI_PART' : 'No MAIN_MAIL_USE_MULTI_PART')."\r\n";
|
||||
$_header .= 'Mime-Version: 1.0'."\r\n";
|
||||
|
||||
// TODO Add also $this->references and In-Reply-To
|
||||
|
||||
return $_header;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3008,10 +3008,24 @@ class Ticket extends CommonObject
|
|||
|
||||
$moreinheader = 'X-Dolibarr-Info: sendTicketMessageByEmail'."\r\n";
|
||||
if (!empty($this->email_msgid)) {
|
||||
$moreinheader .= 'References: <'.$this->email_msgid.'>'."\r\n";
|
||||
// We must also add 1 entry In-Reply-To: <$this->email_msgid> with Message-ID we respond from (See RFC5322).
|
||||
$moreinheader .= 'In-Reply-To: <'.$this->email_msgid.'>'."\r\n";
|
||||
}
|
||||
|
||||
// We should add here also a header 'References:'
|
||||
// According to RFC5322, we should add here all the References fields of the initial message concatenated with
|
||||
// the Message-ID of the message we respond from (but each ID must be once).
|
||||
$references = '';
|
||||
// @TODO
|
||||
// Retrieve source References to do $references .= (empty($references) ? '' : ' ').Source References
|
||||
// If No References is set, use the In-Reply-To for $references .= (empty($references) ? '' : ' ').Source In-reply-To
|
||||
$references .= (empty($references) ? '' : ' ').'<'.$this->email_msgid.'>';
|
||||
if ($references) {
|
||||
$moreinheader .= 'References: '.$references."\r\n";
|
||||
}
|
||||
|
||||
$mailfile = new CMailFile($subject, $receiver, $from, $message, $filepath, $mimetype, $filename, $sendtocc, '', $deliveryreceipt, -1, '', '', $trackid, $moreinheader, 'ticket', '', $upload_dir_tmp);
|
||||
|
||||
if ($mailfile->error) {
|
||||
setEventMessages($mailfile->error, null, 'errors');
|
||||
} else {
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user