diff --git a/htdocs/core/class/CMailFile.class.php b/htdocs/core/class/CMailFile.class.php
index 5288dc635cbec960beafea3183ab745eb74d68f0..573e768fb4b707cfdaa480b6080c943e6465e29b 100644
--- a/htdocs/core/class/CMailFile.class.php
+++ b/htdocs/core/class/CMailFile.class.php
@@ -36,12 +36,12 @@
  */
 class CMailFile
 {
-	var $subject;      // Topic:       Subject of email
-	var $addr_from;    // From:        Label of sender (name but can contains an email inside <>)
-	                   // Sender:      Who send the email ("Sender" has sent emails on behalf of "From").
-	                   //              Use it with an email from a sending host from is a SPF protected domain and sending host is not this domain.
-	                   // Return-Path: Email where to send bounds.
-	var $errors_to;    // Errors-To:   Email where to send errors.
+	var $subject;      	// Topic:       Subject of email
+	var $addr_from;    	// From:		Label and EMail of sender (must include '<>'). For example '<myemail@mydomain.com>' or 'John Doe <myemail@mydomain.com>' or '<myemail+trackingid@mydomain.com>')
+	                   	// Sender:      Who send the email ("Sender" has sent emails on behalf of "From").
+	                   	//              Use it when the "From" is an email of a domain that is a SPF protected domain, and sending smtp server is not this domain. In such case, use for Sender an email of the protected domain.
+	                   	// Return-Path: Email where to send bounds.
+	var $errors_to;		// Errors-To:	Email where to send errors.
 	var $addr_to;
 	var $addr_cc;
 	var $addr_bcc;
diff --git a/htdocs/core/lib/functions2.lib.php b/htdocs/core/lib/functions2.lib.php
index 9a26c727bd4e389afa2f8ef4c70853dd88651e5f..5faf1c1c470001a45d470987c407dc00180c7a43 100644
--- a/htdocs/core/lib/functions2.lib.php
+++ b/htdocs/core/lib/functions2.lib.php
@@ -371,6 +371,21 @@ function dol_print_object_info($object)
     }
 }
 
+
+/**
+ *	Return an email formatted to include a tracking id
+ *  For example  myemail@mydomain.com becom myemail+trackingid@mydomain.com
+ *
+ *	@param	string	$email       	Email address (Ex: "toto@titi.com", "John Do <johndo@titi.com>")
+ *	@param	string	$trackingid    	Tracking id (Ex: thi123 for thirdparty with id 123)
+ *	@return boolean     			True if domain email is OK, False if KO
+ */
+function dolAddEmailTrackId($email, $trackingid)
+{
+	$tmp=explode('@',$email);
+	return $tmp[0].'+'.$trackingid.'@'.(isset($tmp[1])?$tmp[1]:'');
+}
+
 /**
  *	Return true if email has a domain name that can't be resolved
  *
diff --git a/htdocs/societe/soc.php b/htdocs/societe/soc.php
index 04f749dc32a776743fbb9ac2535906aacb52b73e..72dfc8931b84f3edda7e01708ef82e48bb5676c4 100644
--- a/htdocs/societe/soc.php
+++ b/htdocs/societe/soc.php
@@ -259,9 +259,9 @@ if (empty($reshook))
 	                		$action = (($action=='add'||$action=='create')?'create':'edit');
 						}
 					}
-	
+
 					$idprof_mandatory ='SOCIETE_IDPROF'.($i).'_MANDATORY';
-	
+
 					if (! $vallabel && ! empty($conf->global->$idprof_mandatory))
 					{
 						$langs->load("errors");
@@ -2129,6 +2129,11 @@ else
 			$formmail->fromid   = $user->id;
 			$formmail->fromname = $user->getFullName($langs);
 			$formmail->frommail = $user->email;
+			if (! empty($conf->global->MAIN_EMAIL_ADD_TRACK_ID))
+			{
+				include DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
+				$formmail->frommail=dolAddEmailTrackId($formmail->frommail, 'thi'.$object->id);
+			}
 			$formmail->withfrom=1;
 			$formmail->withtopic=1;
 			$liste=array();