diff --git a/model/persistence/SqlElement.php.dist b/model/persistence/SqlElement.php index a579336..867e6d6 100644 --- a/model/persistence/SqlElement.php.dist +++ b/model/persistence/SqlElement.php @@ -3597,8 +3597,9 @@ abstract class SqlElement { $message . '' . ''; + $references = $objectClass . "-" . $this->id; $message = wordwrap($message, 70); // wrapt text so that line do not exceed 70 cars per line - $resultMail=sendMail($dest, $title, $message, $this); + $resultMail=sendMail($dest, $title, $message, $this, null, null, null , null, $references); if ($directStatusMail) { if ($resultMail) { return array('result'=>'OK', 'dest'=>$dest); @@ -4478,4 +4479,4 @@ abstract class SqlElement { } } -?> \ No newline at end of file +?> diff --git a/tool/projeqtor.php.dist b/tool/projeqtor.php index 1349f02..787210f 100644 --- a/tool/projeqtor.php.dist +++ b/tool/projeqtor.php @@ -874,7 +874,7 @@ function getTheme() { * main body of the message * @return unknown_type */ -function sendMail($to, $subject, $messageBody, $object = null, $headers = null, $sender = null, $attachmentsArray = null, $boundary = null) { +function sendMail($to, $subject, $messageBody, $object = null, $headers = null, $sender = null, $attachmentsArray = null, $boundary = null, $references = null) { // Code that caals sendMail : // + SqlElement::sendMailIfMailable() : sendMail($dest, $title, $message, $this) // + Cron::checkImport() : sendMail($to, $title, $message, null, null, null, $attachmentsArray, $boundary); !!! with attachments @@ -890,12 +890,12 @@ function sendMail($to, $subject, $messageBody, $object = null, $headers = null, $paramMailerType = strtolower ( Parameter::getGlobalParameter ( 'paramMailerType' ) ); if (! isset ( $paramMailerType ) or $paramMailerType == '' or $paramMailerType == 'phpmailer') { // Cute method using PHPMailer : should work on all situations / First implementation on V4.0 - return sendMail_phpmailer ( $to, $subject, $messageBody, $object, $headers, $sender, $attachmentsArray ); + return sendMail_phpmailer ( $to, $subject, $messageBody, $object, $headers, $sender, $attachmentsArray, $references ); } else { $messageBody = wordwrap ( $messageBody, 70 ); if ((isset ( $paramMailerType ) and $paramMailerType == 'mail') or ! $paramMailSmtpUsername or ! $paramMailSmtpPassword) { // Standard method using php mail function : do not take authentication into account - return sendMail_mail ( $to, $subject, $messageBody, $object, $headers, $sender, $boundary ); + return sendMail_mail ( $to, $subject, $messageBody, $object, $headers, $sender, $boundary, $references ); } else { // Authentified method using sockets : cannot send vCalendar or mails with attachments return sendMail_socket ( $to, $subject, $messageBody, $object, $headers, $sender, $boundary ); @@ -903,7 +903,7 @@ function sendMail($to, $subject, $messageBody, $object = null, $headers = null, } } -function sendMail_phpmailer($to, $title, $message, $object = null, $headers = null, $sender = null, $attachmentsArray = null) { +function sendMail_phpmailer($to, $title, $message, $object = null, $headers = null, $sender = null, $attachmentsArray = null, $references = null) { scriptLog ( 'sendMail_phpmailer' ); global $logLevel; $paramMailSender = Parameter::getGlobalParameter ( 'paramMailSender' ); @@ -995,6 +995,9 @@ function sendMail_phpmailer($to, $title, $message, $object = null, $headers = nu }else{ $phpmailer->Body = $message; // } + if ($references) { + $phpmailer->addCustomHeader('References', '<' . $references . '.' . $paramMailSender . '>'); + } $phpmailer->CharSet = "UTF-8"; if ($attachmentsArray) { // attachments if (! is_array ( $attachmentsArray )) { @@ -1247,7 +1250,7 @@ function quit($sock) { } } -function sendMail_mail($to, $title, $message, $object = null, $headers = null, $sender = null, $boundary = null) { +function sendMail_mail($to, $title, $message, $object = null, $headers = null, $sender = null, $boundary = null, $references = null) { scriptLog ( 'sendMail_mail' ); $paramMailSender = Parameter::getGlobalParameter ( 'paramMailSender' ); $paramMailReplyTo = Parameter::getGlobalParameter ( 'paramMailReplyTo' ); @@ -1292,7 +1295,10 @@ function sendMail_mail($to, $title, $message, $object = null, $headers = null, $ $headers .= 'From: ' . (($sender) ? $sender : $paramMailSender) . $eol; $headers .= 'Reply-To: ' . (($sender) ? $sender : $paramMailReplyTo) . $eol; $headers .= 'Content-Transfer-Encoding: 8bit' . $eol; - $headers .= 'X-Mailer: PHP/' . phpversion (); + $headers .= 'X-Mailer: PHP/' . phpversion () . $eol; + } + if ($references) { + $headers .= 'References: <' . $references . '.' . $paramMailSender . '>' . $eol; } if (isset ( $paramMailSmtpServer ) and $paramMailSmtpServer) { ini_set ( 'SMTP', $paramMailSmtpServer );