diff --git a/application/loginwebpage.class.inc.php b/application/loginwebpage.class.inc.php index 8a7419610..c19026243 100644 --- a/application/loginwebpage.class.inc.php +++ b/application/loginwebpage.class.inc.php @@ -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); diff --git a/core/action.class.inc.php b/core/action.class.inc.php index e6317819f..bd3d29012 100644 --- a/core/action.class.inc.php +++ b/core/action.class.inc.php @@ -348,7 +348,6 @@ class ActionEmail extends ActionNotification $sTestBody .= "\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); } diff --git a/core/config.class.inc.php b/core/config.class.inc.php index 786480645..6050a9e46 100644 --- a/core/config.class.inc.php +++ b/core/config.class.inc.php @@ -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)', diff --git a/core/email.class.inc.php b/core/email.class.inc.php index 3036f5125..6dcebffc2 100644 --- a/core/email.class.inc.php +++ b/core/email.class.inc.php @@ -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); diff --git a/setup/email.test.php b/setup/email.test.php index 18f386483..4f435fc0a 100644 --- a/setup/email.test.php +++ b/setup/email.test.php @@ -181,7 +181,7 @@ function DisplayStep1(SetupPage $oP) $aForm[] = array( 'label' => "From:", 'input' => "", - 'help' => ' defaults to \'To\'', + 'help' => ' defaults to the configuration param "email_default_sender_address" or "To" field.', ); $oP->form($aForm); $oP->add("\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; diff --git a/synchro/synchrodatasource.class.inc.php b/synchro/synchrodatasource.class.inc.php index 9d8b64592..1058716fc 100644 --- a/synchro/synchrodatasource.class.inc.php +++ b/synchro/synchrodatasource.class.inc.php @@ -1103,14 +1103,12 @@ EOF } $sTo = $oContact->Get($sEmailAttCode); - $sFrom = $sTo; $sBody = '
Data synchronization: '.$this->GetHyperlink().'
'.$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)