mirror of
https://github.com/EGroupware/egroupware.git
synced 2025-02-27 07:42:49 +01:00
email, a new Authentication Method for Cyrus; IMAP username issues, when using loginType email (getMailBoxUserName); using imaplogintype settings to guess the smtp server logintype in case of vmailmgr and email
This commit is contained in:
parent
92ee3ff3c4
commit
b790521c17
@ -75,7 +75,7 @@
|
||||
|
||||
/**
|
||||
* Create mailbox string from given mailbox-name and user-name
|
||||
*
|
||||
* @param string $_username
|
||||
* @param string $_folderName=''
|
||||
* @return string utf-7 encoded (done in getMailboxName)
|
||||
*/
|
||||
@ -86,7 +86,7 @@
|
||||
if(!isset($nameSpaces['others'])) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$_username = $this->getMailBoxUserName($_username);
|
||||
$mailboxString = $nameSpaces['others'][0]['name'] . strtolower($_username) . (!empty($_folderName) ? $nameSpaces['others'][0]['delimiter'] . $_folderName : '');
|
||||
|
||||
if($this->loginType == 'vmailmgr') {
|
||||
@ -147,8 +147,10 @@
|
||||
return false;
|
||||
}
|
||||
|
||||
// create the mailbox
|
||||
// create the mailbox, with the account_lid, as it is passed from the hook values (gets transformed there if needed)
|
||||
$mailboxName = $this->getUserMailboxString($username, $mailboxName);
|
||||
// make sure we use the correct username here.
|
||||
$username = $this->getMailBoxUserName($username);
|
||||
$folderInfo = $this->getMailboxes('', $mailboxName, true);
|
||||
if(empty($folderInfo)) {
|
||||
if(!PEAR::isError($this->createMailbox($mailboxName))) {
|
||||
|
@ -79,7 +79,7 @@
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
var $domainname = false;
|
||||
var $domainName = false;
|
||||
|
||||
/**
|
||||
* validate ssl certificate
|
||||
@ -300,6 +300,29 @@
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* get the effective Username for the Mailbox, as it is depending on the loginType
|
||||
* @param string $_username
|
||||
* @return string the effective username to be used to access the Mailbox
|
||||
*/
|
||||
function getMailBoxUserName($_username)
|
||||
{
|
||||
if ($this->loginType == 'email')
|
||||
{
|
||||
$_username = $_username;
|
||||
$accountemail = $GLOBALS['egw']->accounts->read($GLOBALS['egw']->accounts->name2id($_username,'account_email'));
|
||||
if (!empty($accountemail))
|
||||
{
|
||||
list($username,$domain) = explode('@',$accountemail,2);
|
||||
if (strtolower($domain) == strtolower($this->domainName) && !empty($username))
|
||||
{
|
||||
$_username = $username;
|
||||
}
|
||||
}
|
||||
}
|
||||
return $_username;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create mailbox string from given mailbox-name and user-name
|
||||
*
|
||||
@ -314,13 +337,12 @@
|
||||
return false;
|
||||
}
|
||||
|
||||
$username = $_username;
|
||||
|
||||
if($this->loginType == 'vmailmgr') {
|
||||
$username .= '@'. $this->domainName;
|
||||
$_username = $this->getMailBoxUserName($_username);
|
||||
if($this->loginType == 'vmailmgr' || $this->loginType == 'email') {
|
||||
$_username .= '@'. $this->domainName;
|
||||
}
|
||||
|
||||
$mailboxString = $nameSpaces['others'][0]['name'] . $username . (!empty($_folderName) ? $nameSpaces['others'][0]['delimiter'] . $_folderName : '');
|
||||
$mailboxString = $nameSpaces['others'][0]['name'] . $_username . (!empty($_folderName) ? $nameSpaces['others'][0]['delimiter'] . $_folderName : '');
|
||||
|
||||
return $mailboxString;
|
||||
}
|
||||
@ -401,6 +423,7 @@
|
||||
*/
|
||||
function getQuotaByUser($_username)
|
||||
{
|
||||
$_username = $this->getMailBoxUserName($_username);
|
||||
$mailboxName = $this->getUserMailboxString($_username);
|
||||
$storageQuota = $this->getStorageQuota($mailboxName);
|
||||
|
||||
@ -421,7 +444,7 @@
|
||||
function getUserData($_username)
|
||||
{
|
||||
$this->openConnection(true);
|
||||
|
||||
$_username = $this->getMailBoxUserName($_username);
|
||||
$userData = array();
|
||||
|
||||
if($quota = $this->getQuotaByUser($_username)) {
|
||||
|
@ -231,8 +231,8 @@
|
||||
|
||||
$this->profileData = $this->getProfile($_profileID);
|
||||
|
||||
$this->imapClass =& CreateObject('emailadmin.'.$this->IMAPServerType[$this->profileData['imapType']]['classname']);
|
||||
$this->smtpClass =& CreateObject('emailadmin.'.$this->SMTPServerType[$this->profileData['smtpType']]['classname']);
|
||||
$this->imapClass = CreateObject('emailadmin.'.$this->IMAPServerType[$this->profileData['imapType']]['classname']);
|
||||
$this->smtpClass = CreateObject('emailadmin.'.$this->SMTPServerType[$this->profileData['smtpType']]['classname']);
|
||||
}
|
||||
}
|
||||
|
||||
@ -312,7 +312,7 @@
|
||||
$profileData = $this->getProfile($_profileID);
|
||||
|
||||
#$smtpClass = $this->SMTPServerType[$profileData['smtpType']]['classname'];
|
||||
$smtpClass =& CreateObject('emailadmin.'.$this->SMTPServerType[$profileData['smtpType']]['classname']);
|
||||
$smtpClass = CreateObject('emailadmin.'.$this->SMTPServerType[$profileData['smtpType']]['classname']);
|
||||
|
||||
#return empty($smtpClass) ? False : ExecMethod("emailadmin.$smtpClass.getAccountEmailAddress",$_accountName,3,$profileData);
|
||||
return is_object($smtpClass) ? $smtpClass->getAccountEmailAddress($_accountName) : False;
|
||||
@ -336,7 +336,7 @@
|
||||
# if(!is_object($this->imapClass))
|
||||
# {
|
||||
# $profileData = $this->getProfile($_profileID);
|
||||
# $this->imapClass =& CreateObject('emailadmin.cyrusimap',$profileData);
|
||||
# $this->imapClass = CreateObject('emailadmin.cyrusimap',$profileData);
|
||||
# }
|
||||
#
|
||||
# return $this->imapClass;
|
||||
@ -491,13 +491,13 @@
|
||||
}
|
||||
|
||||
if($data = $this->soemailadmin->getUserProfile($appName, $groups,$GLOBALS['egw_info']['user']['account_id'])) {
|
||||
|
||||
$eaPreferences =& CreateObject('emailadmin.ea_preferences');
|
||||
|
||||
$eaPreferences = CreateObject('emailadmin.ea_preferences');
|
||||
|
||||
// fetch the IMAP / incomming server data
|
||||
$icClass = isset($this->IMAPServerType[$data['imapType']]) ? $this->IMAPServerType[$data['imapType']]['classname'] : 'defaultimap';
|
||||
|
||||
$icServer =& CreateObject('emailadmin.'.$icClass);
|
||||
$icServer = CreateObject('emailadmin.'.$icClass);
|
||||
$icServer->encryption = ($data['imapTLSEncryption'] == 'yes' ? 1 : (int)$data['imapTLSEncryption']);
|
||||
$icServer->host = $data['imapServer'];
|
||||
$icServer->port = $data['imapPort'];
|
||||
@ -522,7 +522,7 @@
|
||||
|
||||
// fetch the SMTP / outgoing server data
|
||||
$ogClass = isset($this->SMTPServerType[$data['smtpType']]) ? $this->SMTPServerType[$data['smtpType']]['classname'] : 'defaultsmtp';
|
||||
$ogServer =& CreateObject('emailadmin.'.$ogClass);
|
||||
$ogServer = CreateObject('emailadmin.'.$ogClass,$icServer->domainName);
|
||||
$ogServer->host = $data['smtpServer'];
|
||||
$ogServer->port = $data['smtpPort'];
|
||||
$ogServer->editForwardingAddress = ($data['editforwardingaddress'] == 'yes');
|
||||
@ -531,7 +531,14 @@
|
||||
if(!empty($data['ea_smtp_auth_username'])) {
|
||||
$ogServer->username = $data['ea_smtp_auth_username'];
|
||||
} else {
|
||||
$ogServer->username = $GLOBALS['egw_info']['user']['account_lid'];
|
||||
// if we use special logintypes for IMAP, we assume this to be used for SMTP too
|
||||
if ($imapAuthType == 'email' || $icServer->loginType == 'email') {
|
||||
$ogServer->username = $GLOBALS['egw_info']['user']['account_email'];
|
||||
} elseif ($icServer->loginType == 'vmailmgr') {
|
||||
$ogServer->username = $GLOBALS['egw_info']['user']['account_lid'].'@'.$icServer->domainName;
|
||||
} else {
|
||||
$ogServer->username = $GLOBALS['egw_info']['user']['account_lid'];
|
||||
}
|
||||
}
|
||||
if(!empty($data['ea_smtp_auth_password'])) {
|
||||
$ogServer->password = $data['ea_smtp_auth_password'];
|
||||
@ -539,11 +546,12 @@
|
||||
$ogServer->password = $GLOBALS['egw_info']['user']['passwd'];
|
||||
}
|
||||
}
|
||||
|
||||
$eaPreferences->setOutgoingServer($ogServer);
|
||||
|
||||
foreach($ogServer->getAccountEmailAddress($GLOBALS['egw_info']['user']['account_lid']) as $emailAddresses)
|
||||
{
|
||||
$identity =& CreateObject('emailadmin.ea_identity');
|
||||
$identity = CreateObject('emailadmin.ea_identity');
|
||||
$identity->emailAddress = $emailAddresses['address'];
|
||||
$identity->realName = $emailAddresses['name'];
|
||||
$identity->default = ($emailAddresses['type'] == 'default');
|
||||
@ -611,7 +619,7 @@
|
||||
{
|
||||
if (is_object($this->smtpClass))
|
||||
{
|
||||
#$smtpClass = &CreateObject('emailadmin.'.$this->smtpClass,$this->profileID);
|
||||
#$smtpClass = CreateObject('emailadmin.'.$this->smtpClass,$this->profileID);
|
||||
#$smtpClass->saveSMTPForwarding($_accountID, $_forwardingAddress, $_keepLocalCopy);
|
||||
$this->smtpClass->saveSMTPForwarding($_accountID, $_forwardingAddress, $_keepLocalCopy);
|
||||
}
|
||||
@ -752,7 +760,7 @@
|
||||
}
|
||||
if (count($new_config))
|
||||
{
|
||||
$config =& CreateObject('phpgwapi.config','phpgwapi');
|
||||
$config = CreateObject('phpgwapi.config','phpgwapi');
|
||||
|
||||
foreach($new_config as $name => $value)
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user