2
0
forked from Wavyzz/dolibarr

Better fix to add server name into email id.

This commit is contained in:
Laurent Destailleur
2016-12-15 12:11:39 +01:00
parent e4dd020887
commit 2c4c48ad6f
3 changed files with 11 additions and 8 deletions

View File

@@ -680,7 +680,7 @@ class CMailFile
global $conf; global $conf;
$out = ""; $out = "";
$host = dol_getprefix(); $host = dol_getprefix('email');
// Sender // Sender
//$out.= "Sender: ".getValidAddress($this->addr_from,2)).$this->eol2; //$out.= "Sender: ".getValidAddress($this->addr_from,2)).$this->eol2;

View File

@@ -1126,7 +1126,7 @@ class SMTPs
$host=preg_replace('@tcp://@i','',$host); // Remove prefix $host=preg_replace('@tcp://@i','',$host); // Remove prefix
$host=preg_replace('@ssl://@i','',$host); // Remove prefix $host=preg_replace('@ssl://@i','',$host); // Remove prefix
$host=dol_getprefix().'-'.$host; $host=dol_getprefix('email').'-'.$host;
//NOTE: Message-ID should probably contain the username of the user who sent the msg //NOTE: Message-ID should probably contain the username of the user who sent the msg
$_header .= 'Subject: ' . $this->getSubject() . "\r\n"; $_header .= 'Subject: ' . $this->getSubject() . "\r\n";

View File

@@ -286,19 +286,22 @@ function GETPOST($paramname,$check='',$method=0,$filter=NULL,$options=NULL)
* This prefix is unique for instance and avoid conflict between multi-instances, * This prefix is unique for instance and avoid conflict between multi-instances,
* even when having two instances with one root dir or two instances in virtual servers * even when having two instances with one root dir or two instances in virtual servers
* *
* @param string $mode '' or 'email'
* @return string A calculated prefix * @return string A calculated prefix
*/ */
function dol_getprefix() function dol_getprefix($mode='')
{ {
global $conf; global $conf;
// If MAIL_PREFIX_FOR_EMAIL_ID is set and prefix is for email
if ($mode == 'email' && ! empty($conf->global->MAIL_PREFIX_FOR_EMAIL_ID))
{
if ($conf->global->MAIL_PREFIX_FOR_EMAIL_ID != 'SERVER_NAME') return $conf->global->MAIL_PREFIX_FOR_EMAIL_ID;
else if (isset($_SERVER["SERVER_NAME"])) return $_SERVER["SERVER_NAME"];
}
if (isset($_SERVER["SERVER_NAME"]) && isset($_SERVER["DOCUMENT_ROOT"])) if (isset($_SERVER["SERVER_NAME"]) && isset($_SERVER["DOCUMENT_ROOT"]))
{ {
if (! empty($conf->global->MAIL_PREFIX_FOR_EMAIL_ID))
{
if ($conf->global->MAIL_PREFIX_FOR_EMAIL_ID == 'SERVER_NAME') return $_SERVER["SERVER_NAME"];
return $conf->global->MAIL_PREFIX_FOR_EMAIL_ID;
}
return dol_hash($_SERVER["SERVER_NAME"].$_SERVER["DOCUMENT_ROOT"].DOL_DOCUMENT_ROOT.DOL_URL_ROOT); return dol_hash($_SERVER["SERVER_NAME"].$_SERVER["DOCUMENT_ROOT"].DOL_DOCUMENT_ROOT.DOL_URL_ROOT);
// Use this for a "clear" cookie name // Use this for a "clear" cookie name
//return dol_sanitizeFileName($_SERVER["SERVER_NAME"].$_SERVER["DOCUMENT_ROOT"].DOL_DOCUMENT_ROOT.DOL_URL_ROOT); //return dol_sanitizeFileName($_SERVER["SERVER_NAME"].$_SERVER["DOCUMENT_ROOT"].DOL_DOCUMENT_ROOT.DOL_URL_ROOT);