mirror of
https://github.com/the-djmaze/snappymail.git
synced 2026-09-07 16:37:02 +03:00
Improved base Domain setup
This commit is contained in:
parent
1dbf2e909f
commit
806f6f3c5e
5 changed files with 53 additions and 59 deletions
|
|
@ -55,31 +55,20 @@ class SnappyMailHelper
|
||||||
if ($ocConfig->getAppValue('snappymail', 'snappymail-autologin', false)
|
if ($ocConfig->getAppValue('snappymail', 'snappymail-autologin', false)
|
||||||
|| $ocConfig->getAppValue('snappymail', 'snappymail-autologin-with-email', false)
|
|| $ocConfig->getAppValue('snappymail', 'snappymail-autologin-with-email', false)
|
||||||
) {
|
) {
|
||||||
$aDomains = \array_unique([
|
$oProvider = \RainLoop\Api::Actions()->DomainProvider();
|
||||||
'nextcloud',
|
$oDomain = $oProvider->Load('nextcloud');
|
||||||
\preg_replace('/:\d+$/','',$_SERVER['HTTP_HOST']),
|
if (!$oDomain) {
|
||||||
$_SERVER['SERVER_NAME'],
|
$oDomain = new \RainLoop\Model\Domain('nextcloud');
|
||||||
\gethostname()
|
$iSecurityType = \MailSo\Net\Enumerations\ConnectionSecurityType::NONE;
|
||||||
]);
|
$oDomain->SetConfig(
|
||||||
foreach ($aDomains as $i => $sDomain) {
|
'localhost', 143, $iSecurityType, true,
|
||||||
if ($sDomain) {
|
true, 'localhost', 4190, $iSecurityType,
|
||||||
$oProvider = \RainLoop\Api::Actions()->DomainProvider();
|
'localhost', 25, $iSecurityType, true, true, false, false,
|
||||||
$oDomain = $oProvider->Load($sDomain);
|
'');
|
||||||
if (!($oDomain instanceof \RainLoop\Model\Domain)) {
|
$oProvider->Save($oDomain);
|
||||||
$oDomain = new \RainLoop\Model\Domain($sDomain);
|
if (!$oConfig->Get('login', 'default_domain', '')) {
|
||||||
$bShortLogin = !$i;
|
$oConfig->Set('login', 'default_domain', 'nextcloud');
|
||||||
$iSecurityType = \MailSo\Net\Enumerations\ConnectionSecurityType::NONE;
|
$bSave = true;
|
||||||
$oDomain->SetConfig(
|
|
||||||
'localhost', 143, $iSecurityType, $bShortLogin,
|
|
||||||
true, 'localhost', 4190, $iSecurityType,
|
|
||||||
'localhost', 25, $iSecurityType, $bShortLogin, true, false, false,
|
|
||||||
'');
|
|
||||||
$oProvider->Save($oDomain);
|
|
||||||
if (!$oConfig->Get('login', 'default_domain', '')) {
|
|
||||||
$oConfig->Set('login', 'default_domain', 'nextcloud');
|
|
||||||
$bSave = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,16 +0,0 @@
|
||||||
imap_host = "localhost"
|
|
||||||
imap_port = 143
|
|
||||||
imap_secure = "None"
|
|
||||||
imap_short_login = Off
|
|
||||||
sieve_use = Off
|
|
||||||
sieve_host = "localhost"
|
|
||||||
sieve_port = 4190
|
|
||||||
sieve_secure = "None"
|
|
||||||
smtp_host = "localhost"
|
|
||||||
smtp_port = 25
|
|
||||||
smtp_secure = "None"
|
|
||||||
smtp_short_login = Off
|
|
||||||
smtp_auth = On
|
|
||||||
smtp_set_sender = Off
|
|
||||||
smtp_php_mail = Off
|
|
||||||
white_list = ""
|
|
||||||
18
snappymail/v/0.0.0/app/domains/default.json
Normal file
18
snappymail/v/0.0.0/app/domains/default.json
Normal file
|
|
@ -0,0 +1,18 @@
|
||||||
|
{
|
||||||
|
"imapHost": "localhost",
|
||||||
|
"imapPort": 143,
|
||||||
|
"imapSecure": 0,
|
||||||
|
"imapShortLogin": false,
|
||||||
|
"useSieve": false,
|
||||||
|
"sieveHost": "localhost",
|
||||||
|
"sievePort": 4190,
|
||||||
|
"sieveSecure": 0,
|
||||||
|
"smtpHost": "localhost",
|
||||||
|
"smtpPort": 25,
|
||||||
|
"smtpSecure": 0,
|
||||||
|
"smtpShortLogin": false,
|
||||||
|
"smtpAuth": true,
|
||||||
|
"smtpSetSender": false,
|
||||||
|
"smtpPhpMail": false,
|
||||||
|
"whiteList": ""
|
||||||
|
}
|
||||||
|
|
@ -368,17 +368,17 @@ class Domain implements \JsonSerializable
|
||||||
if (\strlen($sName) && \strlen($aDomain['imapHost'])) {
|
if (\strlen($sName) && \strlen($aDomain['imapHost'])) {
|
||||||
$oDomain = new self($sName);
|
$oDomain = new self($sName);
|
||||||
|
|
||||||
$oDomain->sIncHost = \MailSo\Base\Utils::IdnToAscii($aDomain['imapHost']);
|
$oDomain->sIncHost = \SnappyMail\IDN::toAscii($aDomain['imapHost']);
|
||||||
$oDomain->iIncPort = (int) $aDomain['imapPort'];
|
$oDomain->iIncPort = (int) $aDomain['imapPort'];
|
||||||
$oDomain->iIncSecure = (int) $aDomain['imapSecure'];
|
$oDomain->iIncSecure = (int) $aDomain['imapSecure'];
|
||||||
$oDomain->bIncShortLogin = !empty($aDomain['imapShortLogin']);
|
$oDomain->bIncShortLogin = !empty($aDomain['imapShortLogin']);
|
||||||
|
|
||||||
$oDomain->bUseSieve = !empty($aDomain['useSieve']);
|
$oDomain->bUseSieve = !empty($aDomain['useSieve']);
|
||||||
$oDomain->sSieveHost = \MailSo\Base\Utils::IdnToAscii($aDomain['sieveHost']);
|
$oDomain->sSieveHost = \SnappyMail\IDN::toAscii($aDomain['sieveHost']);
|
||||||
$oDomain->iSievePort = (int) $aDomain['sievePort'];
|
$oDomain->iSievePort = (int) $aDomain['sievePort'];
|
||||||
$oDomain->iSieveSecure = (int) $aDomain['sieveSecure'];
|
$oDomain->iSieveSecure = (int) $aDomain['sieveSecure'];
|
||||||
|
|
||||||
$oDomain->sOutHost = \MailSo\Base\Utils::IdnToAscii($aDomain['smtpHost']);
|
$oDomain->sOutHost = \SnappyMail\IDN::toAscii($aDomain['smtpHost']);
|
||||||
$oDomain->iOutPort = (int) $aDomain['smtpPort'];
|
$oDomain->iOutPort = (int) $aDomain['smtpPort'];
|
||||||
$oDomain->iOutSecure = (int) $aDomain['smtpSecure'];
|
$oDomain->iOutSecure = (int) $aDomain['smtpSecure'];
|
||||||
$oDomain->bOutShortLogin = !empty($aDomain['smtpShortLogin']);
|
$oDomain->bOutShortLogin = !empty($aDomain['smtpShortLogin']);
|
||||||
|
|
@ -396,16 +396,16 @@ class Domain implements \JsonSerializable
|
||||||
{
|
{
|
||||||
$aResult = array(
|
$aResult = array(
|
||||||
// '@Object' => 'Object/Domain',
|
// '@Object' => 'Object/Domain',
|
||||||
'name' => \MailSo\Base\Utils::IdnToUtf8($this->sName),
|
'name' => \SnappyMail\IDN::toUtf8($this->sName),
|
||||||
'imapHost' => \MailSo\Base\Utils::IdnToUtf8($this->sIncHost),
|
'imapHost' => \SnappyMail\IDN::toUtf8($this->sIncHost),
|
||||||
'imapPort' => $this->iIncPort,
|
'imapPort' => $this->iIncPort,
|
||||||
'imapSecure' => $this->iIncSecure,
|
'imapSecure' => $this->iIncSecure,
|
||||||
'imapShortLogin' => $this->bIncShortLogin,
|
'imapShortLogin' => $this->bIncShortLogin,
|
||||||
'useSieve' => $this->bUseSieve,
|
'useSieve' => $this->bUseSieve,
|
||||||
'sieveHost' => \MailSo\Base\Utils::IdnToUtf8($this->sSieveHost),
|
'sieveHost' => \SnappyMail\IDN::toUtf8($this->sSieveHost),
|
||||||
'sievePort' => $this->iSievePort,
|
'sievePort' => $this->iSievePort,
|
||||||
'sieveSecure' => $this->iSieveSecure,
|
'sieveSecure' => $this->iSieveSecure,
|
||||||
'smtpHost' => \MailSo\Base\Utils::IdnToUtf8($this->sOutHost),
|
'smtpHost' => \SnappyMail\IDN::toUtf8($this->sOutHost),
|
||||||
'smtpPort' => $this->iOutPort,
|
'smtpPort' => $this->iOutPort,
|
||||||
'smtpSecure' => $this->iOutSecure,
|
'smtpSecure' => $this->iOutSecure,
|
||||||
'smtpShortLogin' => $this->bOutShortLogin,
|
'smtpShortLogin' => $this->bOutShortLogin,
|
||||||
|
|
|
||||||
|
|
@ -114,9 +114,9 @@ if (defined('APP_VERSION'))
|
||||||
file_put_contents(APP_DATA_FOLDER_PATH.'INSTALLED', APP_VERSION);
|
file_put_contents(APP_DATA_FOLDER_PATH.'INSTALLED', APP_VERSION);
|
||||||
file_put_contents(APP_DATA_FOLDER_PATH.'index.html', 'Forbidden');
|
file_put_contents(APP_DATA_FOLDER_PATH.'index.html', 'Forbidden');
|
||||||
file_put_contents(APP_DATA_FOLDER_PATH.'index.php', 'Forbidden');
|
file_put_contents(APP_DATA_FOLDER_PATH.'index.php', 'Forbidden');
|
||||||
if (!is_file(APP_DATA_FOLDER_PATH.'.htaccess') && is_file(APP_VERSION_ROOT_PATH.'app/.htaccess'))
|
if (!is_file(APP_DATA_FOLDER_PATH.'.htaccess') && is_file(__DIR__ . '/app/.htaccess'))
|
||||||
{
|
{
|
||||||
copy(APP_VERSION_ROOT_PATH.'app/.htaccess', APP_DATA_FOLDER_PATH.'.htaccess');
|
copy(__DIR__ . '/app/.htaccess', APP_DATA_FOLDER_PATH.'.htaccess');
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!is_dir(APP_PRIVATE_DATA))
|
if (!is_dir(APP_PRIVATE_DATA))
|
||||||
|
|
@ -144,7 +144,7 @@ if (defined('APP_VERSION'))
|
||||||
|
|
||||||
if (!file_exists(APP_PRIVATE_DATA.'domains/disabled') && is_dir(APP_PRIVATE_DATA.'domains'))
|
if (!file_exists(APP_PRIVATE_DATA.'domains/disabled') && is_dir(APP_PRIVATE_DATA.'domains'))
|
||||||
{
|
{
|
||||||
$aFiles = glob(APP_VERSION_ROOT_PATH.'app/domains/*');
|
$aFiles = glob(__DIR__ . '/app/domains/*');
|
||||||
if ($aFiles) {
|
if ($aFiles) {
|
||||||
foreach ($aFiles as $sFile) {
|
foreach ($aFiles as $sFile) {
|
||||||
if (is_file($sFile)) {
|
if (is_file($sFile)) {
|
||||||
|
|
@ -155,14 +155,17 @@ if (defined('APP_VERSION'))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/*
|
|
||||||
$sNewFile = APP_PRIVATE_DATA.'domains/'.gethostname().'.ini';
|
// require __DIR__ . '/app/libraries/snappymail/idn.php';
|
||||||
if (!file_exists($sNewFile)) {
|
// require __DIR__ . '/app/libraries/snappymail/intl/idn.php';
|
||||||
\file_put_contents(
|
// $sName = \SnappyMail\IDN::toAscii(mb_strtolower(gethostname()));
|
||||||
$sNewFile,
|
$sName = mb_strtolower(gethostname());
|
||||||
\str_replace('short_login = Off', 'short_login = On', \file_get_contents(APP_VERSION_ROOT_PATH.'app/domains/default.ini'))
|
$sFile = APP_PRIVATE_DATA.'domains/'.$sName.'.json';
|
||||||
);
|
if (!file_exists($sFile) && !file_exists(APP_PRIVATE_DATA.'domains/'.$sName.'.ini')) {
|
||||||
|
$config = json_decode(file_get_contents(__DIR__ . '/app/domains/default.json'), true);
|
||||||
|
$config['imapShortLogin'] = true;
|
||||||
|
$config['smtpShortLogin'] = true;
|
||||||
|
file_put_contents($sFile, json_encode($config, JSON_PRETTY_PRINT));
|
||||||
}
|
}
|
||||||
*/
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue