N°1319 & N°1203: Added a conf params 'email_default_sender_address' and 'email_default_sender_label' that will be used if a mail has no sender set. (forgot password, test mail, test notification mail, data source fail notification)

SVN:trunk[5750]
This commit is contained in:
Stephen Abello
2018-04-27 08:29:48 +00:00
parent 2be0250aee
commit d441595ee6
6 changed files with 25 additions and 12 deletions

View File

@@ -259,10 +259,6 @@ class LoginWebPage extends NiceWebPage
$oEmail = new Email();
$oEmail->SetRecipientTO($sTo);
$sFrom = MetaModel::GetConfig()->Get('forgot_password_from');
if ($sFrom == '')
{
$sFrom = $sTo;
}
$oEmail->SetRecipientFrom($sFrom);
$oEmail->SetSubject(Dict::S('UI:ResetPwd-EmailSubject'));
$sResetUrl = utils::GetAbsoluteUrlAppRoot().'pages/UI.php?loginop=reset_pwd&auth_user='.urlencode($oUser->Get('login')).'&token='.urlencode($sToken);

View File

@@ -348,7 +348,6 @@ class ActionEmail extends ActionNotification
$sTestBody .= "</div>\n";
$oEmail->SetBody($sTestBody, 'text/html', $sStyles);
$oEmail->SetRecipientTO($this->Get('test_recipient'));
$oEmail->SetRecipientFrom($this->Get('test_recipient'));
$oEmail->SetReferences($sReference);
$oEmail->SetMessageId($sMessageId);
}

View File

@@ -495,6 +495,22 @@ class Config
'source_of_value' => '',
'show_in_conf_sample' => false,
),
'email_default_sender_address' => array(
'type' => 'string',
'description' => 'Default address provided in the email from header field.',
'default' => "",
'value' => "",
'source_of_value' => '',
'show_in_conf_sample' => true,
),
'email_default_sender_label' => array(
'type' => 'string',
'description' => 'Default label provided in the email from header field.',
'default' => "",
'value' => "",
'source_of_value' => '',
'show_in_conf_sample' => true,
),
'apc_cache.enabled' => array(
'type' => 'bool',
'description' => 'If set, the APC cache is allowed (the PHP extension must also be active)',

View File

@@ -260,6 +260,14 @@ class EMail
public function Send(&$aIssues, $bForceSynchronous = false, $oLog = null)
{
//select a default sender if none is provided.
if(empty($this->m_aData['from']['address']))
{
$this->SetRecipientFrom(MetaModel::GetConfig()->Get('email_default_sender_address'), MetaModel::GetConfig()->Get('email_default_sender_label'));
if(empty($this->m_aData['from']['address']) && !empty($this->m_aData['to'])){
$this->SetRecipientFrom($this->m_aData['to']);
}
}
if ($bForceSynchronous)
{
return $this->SendSynchronous($aIssues, $oLog);

View File

@@ -181,7 +181,7 @@ function DisplayStep1(SetupPage $oP)
$aForm[] = array(
'label' => "From:",
'input' => "<input id=\"from\" type=\"text\" name=\"from\" value=\"\">",
'help' => ' defaults to \'To\'',
'help' => ' defaults to the configuration param "email_default_sender_address" or "To" field.',
);
$oP->form($aForm);
$oP->add("</fieldset>\n");
@@ -265,10 +265,6 @@ try
$oP->no_cache();
$sTo = Utils::ReadParam('to', '', false, 'raw_data');
$sFrom = Utils::ReadParam('from', '', false, 'raw_data');
if (strlen($sFrom) == 0)
{
$sFrom = $sTo;
}
DisplayStep2($oP, $sFrom, $sTo);
break;

View File

@@ -1103,14 +1103,12 @@ EOF
}
$sTo = $oContact->Get($sEmailAttCode);
$sFrom = $sTo;
$sBody = '<p>Data synchronization: '.$this->GetHyperlink().'</p>'.$sBody;
$sSubject = 'iTop Data Sync - '.$this->GetName().' - '.$sSubject;
$oEmail = new Email();
$oEmail->SetRecipientTO($sTo);
$oEmail->SetRecipientFrom($sFrom);
$oEmail->SetSubject($sSubject);
$oEmail->SetBody($sBody);
if ($oEmail->Send($aIssues) == EMAIL_SEND_ERROR)