Based on RainLoop discussion #2079,

i've added a security option to set Sender per Domain.
NOTE: Not tested yet
This commit is contained in:
djmaze 2021-03-22 14:17:18 +01:00
parent 10de3b8138
commit f69b1195e6
13 changed files with 75 additions and 28 deletions

View file

@ -168,6 +168,7 @@ class RemoteAdminFetch extends AbstractFetchRemote {
OutSecure: oDomain.smtpSecure(),
OutShortLogin: oDomain.smtpShortLogin() ? 1 : 0,
OutAuth: oDomain.smtpAuth() ? 1 : 0,
OutSetSender: oDomain.smtpSetSender() ? 1 : 0,
OutUsePhpMail: oDomain.smtpPhpMail() ? 1 : 0,
WhiteList: oDomain.whiteList()

View file

@ -47,6 +47,7 @@ class DomainPopupView extends AbstractViewPopup {
smtpSecure: 0,
smtpShortLogin: false,
smtpAuth: true,
smtpSetSender: false,
smtpPhpMail: false,
whiteList: '',
aliasName: '',
@ -298,6 +299,7 @@ class DomainPopupView extends AbstractViewPopup {
this.smtpSecure(oDomain.OutSecure);
this.smtpShortLogin(!!oDomain.OutShortLogin);
this.smtpAuth(!!oDomain.OutAuth);
this.smtpSetSender(!!oDomain.OutSetSender);
this.smtpPhpMail(!!oDomain.OutUsePhpMail);
this.whiteList(oDomain.WhiteList);
this.aliasName(oDomain.AliasName);
@ -333,6 +335,7 @@ class DomainPopupView extends AbstractViewPopup {
this.smtpSecure(0);
this.smtpShortLogin(false);
this.smtpAuth(true);
this.smtpSetSender(true);
this.smtpPhpMail(false);
this.whiteList('');

View file

@ -1013,6 +1013,9 @@ trait Messages
{
$oMessage->SetFrom(new \MailSo\Mime\Email(
$oFromIdentity->Email(), $oFromIdentity->Name()));
if ($oAccount->Domain()->OutSetSender()) {
$oMessage->SetSender(\MailSo\Mime\Email::Parse($oAccount->Email()));
}
}
else
{

View file

@ -58,6 +58,11 @@ class Domain implements \JsonSerializable
*/
private $bOutAuth;
/**
* @var bool
*/
private $bOutSetSender;
/**
* @var bool
*/
@ -97,7 +102,8 @@ class Domain implements \JsonSerializable
string $sIncHost, int $iIncPort, int $iIncSecure, bool $bIncShortLogin,
bool $bUseSieve, string $sSieveHost, int $iSievePort, int $iSieveSecure,
string $sOutHost, int $iOutPort, int $iOutSecure, bool $bOutShortLogin,
bool $bOutAuth, bool $bOutUsePhpMail = false, string $sWhiteList = '')
bool $bOutAuth, bool $bOutSetSender, bool $bOutUsePhpMail = false,
string $sWhiteList = '')
{
$this->sName = $sName;
$this->sIncHost = $sIncHost;
@ -110,6 +116,7 @@ class Domain implements \JsonSerializable
$this->iOutSecure = $iOutSecure;
$this->bOutShortLogin = $bOutShortLogin;
$this->bOutAuth = $bOutAuth;
$this->bOutSetSender = $bOutSetSender;
$this->bOutUsePhpMail = $bOutUsePhpMail;
$this->bUseSieve = $bUseSieve;
@ -145,6 +152,7 @@ class Domain implements \JsonSerializable
!empty($aDomain['smtp_secure']) ? $aDomain['smtp_secure'] : '');
$bOutAuth = !empty($aDomain['smtp_auth']);
$bOutSetSender = !empty($aDomain['smtp_set_sender']);
$bOutUsePhpMail = !empty($aDomain['smtp_php_mail']);
$sWhiteList = (string) ($aDomain['white_list'] ?? '');
@ -154,7 +162,7 @@ class Domain implements \JsonSerializable
$oDomain = new self($sName,
$sIncHost, $iIncPort, $iIncSecure, $bIncShortLogin,
$bUseSieve, $sSieveHost, $iSievePort, $iSieveSecure,
$sOutHost, $iOutPort, $iOutSecure, $bOutShortLogin, $bOutAuth, $bOutUsePhpMail,
$sOutHost, $iOutPort, $iOutSecure, $bOutShortLogin, $bOutAuth, $bOutSetSender, $bOutUsePhpMail,
$sWhiteList);
}
@ -206,6 +214,7 @@ class Domain implements \JsonSerializable
'smtp_secure = "'.self::ConstConnectionSecurityTypeToStr($this->iOutSecure).'"',
'smtp_short_login = '.($this->bOutShortLogin ? 'On' : 'Off'),
'smtp_auth = '.($this->bOutAuth ? 'On' : 'Off'),
'smtp_set_sender = '.($this->bOutSetSender ? 'On' : 'Off'),
'smtp_php_mail = '.($this->bOutUsePhpMail ? 'On' : 'Off'),
'white_list = "'.$this->encodeIniString($this->sWhiteList).'"'
));
@ -246,7 +255,8 @@ class Domain implements \JsonSerializable
string $sIncHost, int $iIncPort, int $iIncSecure, bool $bIncShortLogin,
bool $bUseSieve, string $sSieveHost, int $iSievePort, int $iSieveSecure,
string $sOutHost, int $iOutPort, int $iOutSecure, bool $bOutShortLogin,
bool $bOutAuth, bool $bOutUsePhpMail, string $sWhiteList = '') : self
bool $bOutAuth, bool $bOutSetSender, bool $bOutUsePhpMail,
string $sWhiteList = '') : self
{
$this->sIncHost = \MailSo\Base\Utils::IdnToAscii($sIncHost);
$this->iIncPort = $iIncPort;
@ -263,6 +273,7 @@ class Domain implements \JsonSerializable
$this->iOutSecure = $iOutSecure;
$this->bOutShortLogin = $bOutShortLogin;
$this->bOutAuth = $bOutAuth;
$this->bOutSetSender = $bOutSetSender;
$this->bOutUsePhpMail = $bOutUsePhpMail;
$this->sWhiteList = \trim($sWhiteList);
@ -340,6 +351,11 @@ class Domain implements \JsonSerializable
return $this->bOutAuth;
}
public function OutSetSender() : bool
{
return $this->bOutSetSender;
}
public function OutUsePhpMail() : bool
{
return $this->bOutUsePhpMail;
@ -397,6 +413,7 @@ class Domain implements \JsonSerializable
'OutSecure' => $this->OutSecure(),
'OutShortLogin' => $this->OutShortLogin(),
'OutAuth' => $this->OutAuth(),
'OutSetSender' => $this->OutSetSender(),
'OutUsePhpMail' => $this->OutUsePhpMail(),
'WhiteList' => $this->WhiteList(),
'AliasName' => $this->AliasName()
@ -421,6 +438,7 @@ class Domain implements \JsonSerializable
'OutSecure' => $this->OutSecure(),
'OutShortLogin' => $this->OutShortLogin(),
'OutAuth' => $this->OutAuth(),
'OutSetSender' => $this->OutSetSender(),
'OutUsePhpMail' => $this->OutUsePhpMail(),
'WhiteList' => $this->WhiteList(),
'AliasName' => $this->AliasName()

View file

@ -96,31 +96,33 @@ class Domain extends AbstractProvider
if ($this->bAdmin)
{
$bCreate = '1' === (string) $oActions->GetActionParam('Create', '0');
$sName = (string) $oActions->GetActionParam('Name', '');
$sIncHost = (string) $oActions->GetActionParam('IncHost', '');
$iIncPort = (int) $oActions->GetActionParam('IncPort', 143);
$iIncSecure = (int) $oActions->GetActionParam('IncSecure', \MailSo\Net\Enumerations\ConnectionSecurityType::NONE);
$bIncShortLogin = '1' === (string) $oActions->GetActionParam('IncShortLogin', '0');
$bUseSieve = '1' === (string) $oActions->GetActionParam('UseSieve', '0');
$sSieveHost = (string) $oActions->GetActionParam('SieveHost', '');
$iSievePort = (int) $oActions->GetActionParam('SievePort', 4190);
$iSieveSecure = (int) $oActions->GetActionParam('SieveSecure', \MailSo\Net\Enumerations\ConnectionSecurityType::NONE);
$sOutHost = (string) $oActions->GetActionParam('OutHost', '');
$iOutPort = (int) $oActions->GetActionParam('OutPort', 25);
$iOutSecure = (int) $oActions->GetActionParam('OutSecure', \MailSo\Net\Enumerations\ConnectionSecurityType::NONE);
$bOutShortLogin = '1' === (string) $oActions->GetActionParam('OutShortLogin', '0');
$bOutAuth = '1' === (string) $oActions->GetActionParam('OutAuth', '1');
$bOutUsePhpMail = '1' === (string) $oActions->GetActionParam('OutUsePhpMail', '0');
$sWhiteList = (string) $oActions->GetActionParam('WhiteList', '');
if (0 < \strlen($sName) && 0 < strlen($sNameForTest) && false === \strpos($sName, '*'))
if (0 < \strlen($sName) && 0 < \strlen($sNameForTest) && !\str_contains($sName, '*'))
{
$sNameForTest = '';
}
if (0 < strlen($sName) || 0 < strlen($sNameForTest))
{
$bCreate = '1' === (string) $oActions->GetActionParam('Create', '0');
$sIncHost = (string) $oActions->GetActionParam('IncHost', '');
$iIncPort = (int) $oActions->GetActionParam('IncPort', 143);
$iIncSecure = (int) $oActions->GetActionParam('IncSecure', \MailSo\Net\Enumerations\ConnectionSecurityType::NONE);
$bIncShortLogin = '1' === (string) $oActions->GetActionParam('IncShortLogin', '0');
$bUseSieve = '1' === (string) $oActions->GetActionParam('UseSieve', '0');
$sSieveHost = (string) $oActions->GetActionParam('SieveHost', '');
$iSievePort = (int) $oActions->GetActionParam('SievePort', 4190);
$iSieveSecure = (int) $oActions->GetActionParam('SieveSecure', \MailSo\Net\Enumerations\ConnectionSecurityType::NONE);
$sOutHost = (string) $oActions->GetActionParam('OutHost', '');
$iOutPort = (int) $oActions->GetActionParam('OutPort', 25);
$iOutSecure = (int) $oActions->GetActionParam('OutSecure', \MailSo\Net\Enumerations\ConnectionSecurityType::NONE);
$bOutShortLogin = '1' === (string) $oActions->GetActionParam('OutShortLogin', '0');
$bOutAuth = '1' === (string) $oActions->GetActionParam('OutAuth', '1');
$bOutSetSender = '1' === (string) $oActions->GetActionParam('OutSetSender', '0');
$bOutUsePhpMail = '1' === (string) $oActions->GetActionParam('OutUsePhpMail', '0');
$sWhiteList = (string) $oActions->GetActionParam('WhiteList', '');
$oDomain = 0 < strlen($sNameForTest) ? null : $this->Load($sName);
if ($oDomain instanceof \RainLoop\Model\Domain)
{
@ -133,7 +135,7 @@ class Domain extends AbstractProvider
$oDomain->UpdateInstance(
$sIncHost, $iIncPort, $iIncSecure, $bIncShortLogin,
$bUseSieve, $sSieveHost, $iSievePort, $iSieveSecure,
$sOutHost, $iOutPort, $iOutSecure, $bOutShortLogin, $bOutAuth, $bOutUsePhpMail,
$sOutHost, $iOutPort, $iOutSecure, $bOutShortLogin, $bOutAuth, $bOutSetSender, $bOutUsePhpMail,
$sWhiteList);
}
}
@ -142,7 +144,7 @@ class Domain extends AbstractProvider
$oDomain = new \RainLoop\Model\Domain(0 < strlen($sNameForTest) ? $sNameForTest : $sName,
$sIncHost, $iIncPort, $iIncSecure, $bIncShortLogin,
$bUseSieve, $sSieveHost, $iSievePort, $iSieveSecure,
$sOutHost, $iOutPort, $iOutSecure, $bOutShortLogin, $bOutAuth, $bOutUsePhpMail,
$sOutHost, $iOutPort, $iOutSecure, $bOutShortLogin, $bOutAuth, $bOutSetSender, $bOutUsePhpMail,
$sWhiteList);
}
}
@ -172,6 +174,7 @@ class Domain extends AbstractProvider
$iOutSecure = (int) $oActions->GetActionParam('OutSecure', \MailSo\Net\Enumerations\ConnectionSecurityType::NONE);
$bOutShortLogin = '1' === (string) $oActions->GetActionParam('OutShortLogin', '0');
$bOutAuth = '1' === (string) $oActions->GetActionParam('OutAuth', '1');
$bOutSetSender = '1' === (string) $oActions->GetActionParam('OutSetSender', '0');
$bOutUsePhpMail = '1' === (string) $oActions->GetActionParam('OutUsePhpMail', '0');
$sWhiteList = (string) $oActions->GetActionParam('WhiteList', '');
@ -194,7 +197,7 @@ class Domain extends AbstractProvider
$oDomain->UpdateInstance(
$sIncHost, $iIncPort, $iIncSecure, $bIncShortLogin,
$bUseSieve, $sSieveHost, $iSievePort, $iSieveSecure,
$sOutHost, $iOutPort, $iOutSecure, $bOutShortLogin, $bOutAuth, $bOutUsePhpMail,
$sOutHost, $iOutPort, $iOutSecure, $bOutShortLogin, $bOutAuth, $bOutSetSender, $bOutUsePhpMail,
$sWhiteList);
}
}
@ -203,7 +206,7 @@ class Domain extends AbstractProvider
$oDomain = new \RainLoop\Model\Domain(0 < strlen($sNameForTest) ? $sNameForTest : $sName,
$sIncHost, $iIncPort, $iIncSecure, $bIncShortLogin,
$bUseSieve, $sSieveHost, $iSievePort, $iSieveSecure,
$sOutHost, $iOutPort, $iOutSecure, $bOutShortLogin, $bOutAuth, $bOutUsePhpMail,
$sOutHost, $iOutPort, $iOutSecure, $bOutShortLogin, $bOutAuth, $bOutSetSender, $bOutUsePhpMail,
$sWhiteList);
}
}

View file

@ -133,6 +133,7 @@ en:
LABEL_ALLOW_SIEVE_SCRIPTS: "Allow sieve scripts"
LABEL_USE_SHORT_LOGIN: "Use short login"
LABEL_USE_AUTH: "Use authentication"
LABEL_SET_SENDER: "Use login as sender"
LABEL_USE_PHP_MAIL: "Use php mail() function"
BUTTON_TEST: "Test"
BUTTON_WHITE_LIST: "White List"

View file

@ -129,6 +129,7 @@ de_DE:
LABEL_ALLOW_SIEVE_SCRIPTS: "Sieve-Skripte erlauben"
LABEL_USE_SHORT_LOGIN: "Kurze Benutzernamen verwenden"
LABEL_USE_AUTH: "Authentifizierung verwenden"
LABEL_SET_SENDER: "Verwenden Sie die Anmeldung als Absender"
LABEL_USE_PHP_MAIL: "PHPs mail()-Funktion verwenden"
BUTTON_TEST: "Testen"
BUTTON_WHITE_LIST: "Whitelist"

View file

@ -130,6 +130,7 @@ en_US:
LABEL_ALLOW_SIEVE_SCRIPTS: "Allow sieve scripts"
LABEL_USE_SHORT_LOGIN: "Use short login"
LABEL_USE_AUTH: "Use authentication"
LABEL_SET_SENDER: "Use login as sender"
LABEL_USE_PHP_MAIL: "Use php mail() function"
BUTTON_TEST: "Test"
BUTTON_WHITE_LIST: "White List"

View file

@ -130,6 +130,7 @@ es_ES:
LABEL_ALLOW_SIEVE_SCRIPTS: "Permitir scripts de filtro"
LABEL_USE_SHORT_LOGIN: "Inicio de Sesión corto"
LABEL_USE_AUTH: "Usar autenticación"
LABEL_SET_SENDER: "Usar inicio de sesión como remitente"
LABEL_USE_PHP_MAIL: "Utilizar la función mail() de PHP"
BUTTON_TEST: "Probar"
BUTTON_WHITE_LIST: "Lista blanca"

View file

@ -130,6 +130,7 @@ fr_FR:
LABEL_ALLOW_SIEVE_SCRIPTS: "Autoriser les scripts sieve"
LABEL_USE_SHORT_LOGIN: "Utiliser l'identifiant court"
LABEL_USE_AUTH: "Utiliser l'authentification"
LABEL_SET_SENDER: "Utiliser la connexion en tant qu'expéditeur"
LABEL_USE_PHP_MAIL: "Utiliser la fonction mail() de php"
BUTTON_TEST: "Test"
BUTTON_WHITE_LIST: "Liste Blanche"

View file

@ -129,6 +129,7 @@ nl_NL:
LABEL_ALLOW_SIEVE_SCRIPTS: "Sta Sieve scripts toe"
LABEL_USE_SHORT_LOGIN: "Gebruik verkorte login"
LABEL_USE_AUTH: "Gebruik authenticatie"
LABEL_SET_SENDER: "Gebruik login als verzender"
LABEL_USE_PHP_MAIL: "Gebruik php mail() functie"
BUTTON_TEST: "Test"
BUTTON_WHITE_LIST: "Witte lijst"

View file

@ -131,6 +131,7 @@ zh_CN:
LABEL_ALLOW_SIEVE_SCRIPTS: "可使用筛选脚本"
LABEL_USE_SHORT_LOGIN: "使用短用户名登录"
LABEL_USE_AUTH: "使用认证"
LABEL_SET_SENDER: "使用登录名作为发件人"
LABEL_USE_PHP_MAIL: "使用 php mail() 函数"
BUTTON_TEST: "测试"
BUTTON_WHITE_LIST: "白名单"

View file

@ -49,7 +49,6 @@
data-bind="textInput: imapPort" />
</div>
</div>
<br />
<div class="row">
<div class="span4">
<span data-i18n="POPUPS_DOMAIN/LABEL_SECURE"></span>
@ -115,7 +114,6 @@
data-bind="textInput: sievePort" />
</div>
</div>
<br />
<div class="row">
<div class="span4">
<span data-i18n="POPUPS_DOMAIN/LABEL_SECURE"></span>
@ -161,7 +159,6 @@
data-bind="textInput: smtpPort" />
</div>
</div>
<br />
<div class="row">
<div class="span4">
<span data-i18n="POPUPS_DOMAIN/LABEL_SECURE"></span>
@ -186,7 +183,10 @@
}"></div>
&nbsp;&nbsp;
<span style="color: #aaa">(user@domain.com → user)</span>
<br />
</div>
</div>
<div class="row">
<div class="span5">
<div data-bind="component: {
name: 'Checkbox',
params: {
@ -198,6 +198,18 @@
</div>
<br />
</div>
<div class="row">
<div class="span5">
<div data-bind="component: {
name: 'Checkbox',
params: {
label: 'POPUPS_DOMAIN/LABEL_SET_SENDER',
value: smtpSetSender,
inline: true
}
}"></div>
</div>
</div>
<div class="row">
<div class="span5">
<div data-bind="component: {