New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Auto Detect Server from Email Address #863
Comments
Take a look at these search results. Not sure if it helps, but maybe setting |
Hi There! Thanks for the response. I did try that, however I realised it would only work if we were using one server. Due to the requirement of still having to specify the specific server to manage the wildcard domain, even though all addresses are allowed, they would all be pointed towards one imap server instead of each to their separate server :/ |
Oh Cool! Just discovered this from one of the links. I'll check it out! https://github.com/RainLoop/rainloop-webmail/tree/master/plugins/override-smtp-credentials |
Hey there, I used that plugin (override-smtp-credentials) to build a custom plugin that does exactly this for IMAP and SMTP. Looking into fixing up the code a bit and possibly adding it to the plugins here on GitHub |
Hi Jas! If you could send that my way, I would really appreciate it. I could possibly take a look and help? Rhys |
Hey Rhys, Here's what it looks like: /**
* Based on:
* https://github.com/RainLoop/rainloop-webmail/blob/master/plugins/override-smtp-credentials/index.php
*/
class OverrideServerAddressesPlugin extends \RainLoop\Plugins\AbstractPlugin
{
public function Init()
{
$this->addHook('filter.smtp-credentials', 'FilterSmtpCredentials');
$this->addHook('filter.imap-credentials', 'FilterImapCredentials');
}
/**
* @param \RainLoop\Model\Account $oAccount
* @param array $aSmtpCredentials
*/
public function FilterSmtpCredentials($oAccount, &$aSmtpCredentials)
{
if ($oAccount instanceof \RainLoop\Model\Account && \is_array($aSmtpCredentials))
{
$sEmail = $oAccount->Email();
// Check for mail.$DOMAIN as entered value in RL settings
if ( $aSmtpCredentials['Host'] == "mail.%DOMAIN" || $aSmtpCredentials['Host'] == "" )
{
$aSmtpCredentials['Host'] = "mail." . $this->getDomainFromEmail($sEmail);
}
}
}
/**
* @param \RainLoop\Model\Account $oAccount
* @param array $aImapCredentials
*/
public function FilterImapCredentials($oAccount, &$aImapCredentials)
{
if ($oAccount instanceof \RainLoop\Model\Account && \is_array($aImapCredentials))
{
$sEmail = $oAccount->Email();
// Check for mail.$DOMAIN as entered value in RL settings
if ( $aImapCredentials['Host'] == "mail.%DOMAIN" || $aImapCredentials['Host'] == "" )
{
$aImapCredentials['Host'] = "mail." . $this->getDomainFromEmail($sEmail);
}
}
}
/**
* @param string $emailAdress
* @return string
*/
private function getDomainFromEmail($emailAddress){
$parts = explode("@", trim($emailAddress));
return $parts[1];
}
} I intended to add some documentation to the plugin by specifying that using wildcards like %DOMAIN would be replaced by the actual domain used in the email address, but didn't get around to it. Hopefully this can be turned into a more official plugin for allowing such functionality! Note that this will also work with a wildcard Domain value in the RL settings even if you leave the server fields empty. Perhaps that should be tweaked... |
Awesome stuff! Looks perfect already |
Alright! Here we go Jas. You can make a pull request with the extracted folder directly to the RainLoop plugins folder. It is all ready and works well :) I've put usage instructions and a licence with it, so feel free to change/remove if you'd like. https://cloud.rhysit.co.za/index.php/s/cXHQZa1PukjtYZn Rhys |
Hi Jas, Should I make the request? |
Hey Rhys, Looks good! Which request is that? -J |
Pull request to the repo :) Let me know if you'd like me to. Rhys |
Ah, yes I thought that's what you meant. Go for it! |
Cool will do |
👍 |
Small refactoring: e8fbdff |
Perfect! Looks good. I'm sure this plugin will help a lot of those in need :) |
Hi There,
Is there any chance of setting up RainLoop as a single interface for multiple shared hosting servers (i.e. many clients with many addresses spread over multiple servers). In this case, the server name would need to be read in from the email address automatically,
For example:
info@rhysit.co.za
password
RainLoop auto detects the server name 'rhysit.co.za', and attempts to log in using
'info@rhysit.co.za' as the username,
'password' as the password,
'rhysit.co.za' as the server.
Thanks
Rhys
The text was updated successfully, but these errors were encountered: