mirror of
https://github.com/the-djmaze/snappymail.git
synced 2026-08-29 12:09:20 +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)
|
||||
|| $ocConfig->getAppValue('snappymail', 'snappymail-autologin-with-email', false)
|
||||
) {
|
||||
$aDomains = \array_unique([
|
||||
'nextcloud',
|
||||
\preg_replace('/:\d+$/','',$_SERVER['HTTP_HOST']),
|
||||
$_SERVER['SERVER_NAME'],
|
||||
\gethostname()
|
||||
]);
|
||||
foreach ($aDomains as $i => $sDomain) {
|
||||
if ($sDomain) {
|
||||
$oProvider = \RainLoop\Api::Actions()->DomainProvider();
|
||||
$oDomain = $oProvider->Load($sDomain);
|
||||
if (!($oDomain instanceof \RainLoop\Model\Domain)) {
|
||||
$oDomain = new \RainLoop\Model\Domain($sDomain);
|
||||
$bShortLogin = !$i;
|
||||
$iSecurityType = \MailSo\Net\Enumerations\ConnectionSecurityType::NONE;
|
||||
$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;
|
||||
}
|
||||
}
|
||||
$oProvider = \RainLoop\Api::Actions()->DomainProvider();
|
||||
$oDomain = $oProvider->Load('nextcloud');
|
||||
if (!$oDomain) {
|
||||
$oDomain = new \RainLoop\Model\Domain('nextcloud');
|
||||
$iSecurityType = \MailSo\Net\Enumerations\ConnectionSecurityType::NONE;
|
||||
$oDomain->SetConfig(
|
||||
'localhost', 143, $iSecurityType, true,
|
||||
true, 'localhost', 4190, $iSecurityType,
|
||||
'localhost', 25, $iSecurityType, true, 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'])) {
|
||||
$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->iIncSecure = (int) $aDomain['imapSecure'];
|
||||
$oDomain->bIncShortLogin = !empty($aDomain['imapShortLogin']);
|
||||
|
||||
$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->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->iOutSecure = (int) $aDomain['smtpSecure'];
|
||||
$oDomain->bOutShortLogin = !empty($aDomain['smtpShortLogin']);
|
||||
|
|
@ -396,16 +396,16 @@ class Domain implements \JsonSerializable
|
|||
{
|
||||
$aResult = array(
|
||||
// '@Object' => 'Object/Domain',
|
||||
'name' => \MailSo\Base\Utils::IdnToUtf8($this->sName),
|
||||
'imapHost' => \MailSo\Base\Utils::IdnToUtf8($this->sIncHost),
|
||||
'name' => \SnappyMail\IDN::toUtf8($this->sName),
|
||||
'imapHost' => \SnappyMail\IDN::toUtf8($this->sIncHost),
|
||||
'imapPort' => $this->iIncPort,
|
||||
'imapSecure' => $this->iIncSecure,
|
||||
'imapShortLogin' => $this->bIncShortLogin,
|
||||
'useSieve' => $this->bUseSieve,
|
||||
'sieveHost' => \MailSo\Base\Utils::IdnToUtf8($this->sSieveHost),
|
||||
'sieveHost' => \SnappyMail\IDN::toUtf8($this->sSieveHost),
|
||||
'sievePort' => $this->iSievePort,
|
||||
'sieveSecure' => $this->iSieveSecure,
|
||||
'smtpHost' => \MailSo\Base\Utils::IdnToUtf8($this->sOutHost),
|
||||
'smtpHost' => \SnappyMail\IDN::toUtf8($this->sOutHost),
|
||||
'smtpPort' => $this->iOutPort,
|
||||
'smtpSecure' => $this->iOutSecure,
|
||||
'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.'index.html', '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))
|
||||
|
|
@ -144,7 +144,7 @@ if (defined('APP_VERSION'))
|
|||
|
||||
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) {
|
||||
foreach ($aFiles as $sFile) {
|
||||
if (is_file($sFile)) {
|
||||
|
|
@ -155,14 +155,17 @@ if (defined('APP_VERSION'))
|
|||
}
|
||||
}
|
||||
}
|
||||
/*
|
||||
$sNewFile = APP_PRIVATE_DATA.'domains/'.gethostname().'.ini';
|
||||
if (!file_exists($sNewFile)) {
|
||||
\file_put_contents(
|
||||
$sNewFile,
|
||||
\str_replace('short_login = Off', 'short_login = On', \file_get_contents(APP_VERSION_ROOT_PATH.'app/domains/default.ini'))
|
||||
);
|
||||
|
||||
// require __DIR__ . '/app/libraries/snappymail/idn.php';
|
||||
// require __DIR__ . '/app/libraries/snappymail/intl/idn.php';
|
||||
// $sName = \SnappyMail\IDN::toAscii(mb_strtolower(gethostname()));
|
||||
$sName = mb_strtolower(gethostname());
|
||||
$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