mirror of
https://github.com/EGroupware/egroupware.git
synced 2024-11-25 09:23:28 +01:00
Fix email identity with no domain part set
This commit is contained in:
parent
75124d097b
commit
73e2243b33
@ -1336,6 +1336,12 @@ class admin_mail
|
||||
}
|
||||
$content['admin_actions'] = (bool)$admin_actions;
|
||||
|
||||
//try to fix identities with no domain part set e.g. alias as identity
|
||||
if (!strpos($content['ident_email'], '@'))
|
||||
{
|
||||
$content['ident_email'] = Mail::fixInvalidAliasAddress (Api\Accounts::id2name($content['acc_imap_account_id'], 'account_email'), $content['ident_email']);
|
||||
}
|
||||
|
||||
$tpl->exec(static::APP_CLASS.'edit', $content, $sel_options, $readonlys, $content, 2);
|
||||
}
|
||||
|
||||
|
@ -296,6 +296,22 @@ class Mail
|
||||
return self::$instances[$_profileID];
|
||||
}
|
||||
|
||||
/**
|
||||
* This method tries to fix alias address lacking domain part
|
||||
* by trying to add domain part extracted from given reference address
|
||||
*
|
||||
* @param string $refrence email address to be used for domain extraction
|
||||
* @param string $address alias address
|
||||
*
|
||||
* @return string returns alias address with appended default domain
|
||||
*/
|
||||
public static function fixInvalidAliasAddress($refrence, $address)
|
||||
{
|
||||
$parts = explode('@', $refrence);
|
||||
if (!strpos($address,'@') && !empty($parts[1])) $address .= '@'.$parts[1];
|
||||
return $address;
|
||||
}
|
||||
|
||||
/**
|
||||
* store given ProfileID to Session and pref
|
||||
*
|
||||
|
@ -418,7 +418,7 @@ class mail_sieve
|
||||
*
|
||||
* @param string $accountID
|
||||
*
|
||||
* @return array return multi-dimentional array of vacation and aliases
|
||||
* @return array return multi-dimensional array of vacation and aliases
|
||||
*/
|
||||
function getVacation($accountID = null)
|
||||
{
|
||||
@ -445,21 +445,25 @@ class mail_sieve
|
||||
}
|
||||
if (is_null($accountID)) $accountID = $GLOBALS['egw_info']['user']['account_id'];
|
||||
|
||||
$account_email = Api\Accounts::id2name($accountID, 'account_email');
|
||||
$accAllIdentities = $this->account->smtpServer()->getAccountEmailAddress(Api\Accounts::id2name($accountID));
|
||||
$allAliases = $this->account->ident_email !=''? array($this->account->ident_email): array();
|
||||
$allAliases = $this->account->ident_email !=''?
|
||||
// Fix ident_email with no domain part set
|
||||
array(Mail::fixInvalidAliasAddress($account_email, $this->account->ident_email))
|
||||
: array();
|
||||
foreach ($accAllIdentities as &$val)
|
||||
{
|
||||
if ($val['type'] !='default')
|
||||
{
|
||||
// if the alias has no domain part set try to add
|
||||
// default domain extracted from ident_email address
|
||||
$allAliases[] = self::fixInvalidAliasAddress($this->account->ident_email, $val['address']);
|
||||
$allAliases[] = Mail::fixInvalidAliasAddress($account_email, $val['address']);
|
||||
}
|
||||
}
|
||||
// try to fix already stored aliases
|
||||
foreach ($vacation['addresses'] as &$address)
|
||||
{
|
||||
$address = self::fixInvalidAliasAddress($this->account->ident_email, $address);
|
||||
$address = Mail::fixInvalidAliasAddress($account_email, $address);
|
||||
}
|
||||
asort($allAliases);
|
||||
return array(
|
||||
@ -468,22 +472,6 @@ class mail_sieve
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* This method tries to fix alias address lacking domain part
|
||||
* by trying to add domain extracted from given reference address
|
||||
*
|
||||
* @param string $refrence email address to be used for domain extraction
|
||||
* @param string $address alias address
|
||||
*
|
||||
* @return string returns alias address with appended default domain
|
||||
*/
|
||||
static function fixInvalidAliasAddress($refrence, $address)
|
||||
{
|
||||
$parts = explode('@', $refrence);
|
||||
if (!strpos($address,'@') && !empty($parts[1])) $address .= '@'.$parts[1];
|
||||
return $address;
|
||||
}
|
||||
|
||||
/**
|
||||
* Vacation edit
|
||||
*
|
||||
|
Loading…
Reference in New Issue
Block a user