mirror of
https://github.com/the-djmaze/snappymail.git
synced 2026-08-25 10:09:20 +03:00
Merge f9cd95fdce into c154d23cfe
This commit is contained in:
commit
fd1da23cbf
1 changed files with 29 additions and 6 deletions
|
|
@ -1,10 +1,10 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This extension automatically detects the IMAP and SMTP settings by
|
* This extension automatically detects the IMAP, SMTP, and Sieve settings by
|
||||||
* extracting them from the email address itself. For example, if the user
|
* extracting them from the email address itself. For example, if the user
|
||||||
* attemps to login as 'info@example.com', then the IMAP and SMTP host would
|
* attemps to login as 'info@example.com', then the IMAP, SMTP, and Sieve host
|
||||||
* be set to to 'example.com'.
|
* would be set to to 'example.com'.
|
||||||
*
|
*
|
||||||
* Based on:
|
* Based on:
|
||||||
* https://github.com/the-djmaze/snappymail/blob/master/plugins/override-smtp-credentials/index.php
|
* https://github.com/the-djmaze/snappymail/blob/master/plugins/override-smtp-credentials/index.php
|
||||||
|
|
@ -19,15 +19,17 @@ class AutoDomainGrabPlugin extends \RainLoop\Plugins\AbstractPlugin
|
||||||
RELEASE = '2022-11-11',
|
RELEASE = '2022-11-11',
|
||||||
REQUIRED = '2.21.0',
|
REQUIRED = '2.21.0',
|
||||||
CATEGORY = 'General',
|
CATEGORY = 'General',
|
||||||
DESCRIPTION = 'Sets the IMAP/SMTP host based on the user\'s login';
|
DESCRIPTION = 'Sets the IMAP, SMTP, Sieve host based on the user\'s login';
|
||||||
|
|
||||||
private $imap_prefix = 'mail.';
|
private $imap_prefix = 'mail.';
|
||||||
private $smtp_prefix = 'mail.';
|
private $smtp_prefix = 'mail.';
|
||||||
|
private $sieve_prefix = 'mail.';
|
||||||
|
|
||||||
public function Init() : void
|
public function Init() : void
|
||||||
{
|
{
|
||||||
$this->addHook('smtp.before-connect', 'FilterSmtpCredentials');
|
|
||||||
$this->addHook('imap.before-connect', 'FilterImapCredentials');
|
$this->addHook('imap.before-connect', 'FilterImapCredentials');
|
||||||
|
$this->addHook('smtp.before-connect', 'FilterSmtpCredentials');
|
||||||
|
$this->addHook('sieve.before-connect', 'FilterSieveCredentials');
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -71,4 +73,25 @@ class AutoDomainGrabPlugin extends \RainLoop\Plugins\AbstractPlugin
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This function detects the Sieve Host, and if it is set to 'auto', replaces it with the MX or email domain.
|
||||||
|
*/
|
||||||
|
public function FilterSieveCredentials(\RainLoop\Model\Account $oAccount, \MailSo\Sieve\SieveClient $oSieveClient, \MailSo\Sieve\Settings $oSettings)
|
||||||
|
{
|
||||||
|
// Check for mail.$DOMAIN as entered value in RL settings
|
||||||
|
if ('auto' === $oSettings->host)
|
||||||
|
{
|
||||||
|
$domain = \substr(\strrchr($oAccount->Email(), '@'), 1);
|
||||||
|
$mxhosts = array();
|
||||||
|
if (\getmxrr($domain, $mxhosts) && $mxhosts)
|
||||||
|
{
|
||||||
|
$oSettings->host = $mxhosts[0];
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$oSettings->host = $this->sieve_prefix.$domain;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue