From d441595ee60f834ea179c7ee19195ca31b1f1e31 Mon Sep 17 00:00:00 2001 From: Stephen Abello Date: Fri, 27 Apr 2018 08:29:48 +0000 Subject: [PATCH] =?UTF-8?q?N=C2=B01319=20&=20N=C2=B01203:=20Added=20a=20co?= =?UTF-8?q?nf=20params=20'email=5Fdefault=5Fsender=5Faddress'=20and=20'ema?= =?UTF-8?q?il=5Fdefault=5Fsender=5Flabel'=20that=20will=20be=20used=20if?= =?UTF-8?q?=20a=20mail=20has=20no=20sender=20set.=20(forgot=20password,=20?= =?UTF-8?q?test=20mail,=20test=20notification=20mail,=20data=20source=20fa?= =?UTF-8?q?il=20notification)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit SVN:trunk[5750] --- application/loginwebpage.class.inc.php | 4 ---- core/action.class.inc.php | 1 - core/config.class.inc.php | 16 ++++++++++++++++ core/email.class.inc.php | 8 ++++++++ setup/email.test.php | 6 +----- synchro/synchrodatasource.class.inc.php | 2 -- 6 files changed, 25 insertions(+), 12 deletions(-) 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)