Avoid duplicating from email address when generating identity

This commit is contained in:
Hadi Nategh 2022-01-10 14:03:14 +01:00
parent b1de5e3881
commit 5625695c26
2 changed files with 5 additions and 4 deletions

View File

@ -2463,7 +2463,7 @@ class mail_compose
$email_From = $_identity['ident_email'] ? $_identity['ident_email'] : $activeMailProfile['ident_email']; $email_From = $_identity['ident_email'] ? $_identity['ident_email'] : $activeMailProfile['ident_email'];
// Try to fix identity email with no domain part set // Try to fix identity email with no domain part set
$_mailObject->setFrom(Mail::fixInvalidAliasAddress(Api\Accounts::id2name($_identity['account_id'], 'account_email'), $email_From), $_mailObject->setFrom(Mail::fixInvalidAliasAddress(Api\Accounts::id2name($_identity['account_id'], 'account_email'), $email_From),
mail_tree::getIdentityName($_identity)); mail_tree::getIdentityName($_identity, false));
$_mailObject->addHeader('X-Priority', $_formData['priority']); $_mailObject->addHeader('X-Priority', $_formData['priority']);
$_mailObject->addHeader('X-Mailer', 'EGroupware-Mail'); $_mailObject->addHeader('X-Mailer', 'EGroupware-Mail');

View File

@ -543,9 +543,10 @@ class mail_tree
* Build folder tree parent identity label * Build folder tree parent identity label
* *
* @param array $_account * @param array $_account
* @param bool $_fullString = true full or false=NamePart only is returned
* @return string * @return string
*/ */
static function getIdentityName ($_account) static function getIdentityName ($_account, bool $_fullString=true)
{ {
$identLabel = $GLOBALS['egw_info']['user']['preferences']['mail']['identLabel']; $identLabel = $GLOBALS['egw_info']['user']['preferences']['mail']['identLabel'];
$name = array(); $name = array();
@ -567,12 +568,12 @@ class mail_tree
if ($identLabel & self::ORG_NAME_EMAIL) if ($identLabel & self::ORG_NAME_EMAIL)
{ {
$name[] = $_account['ident_org']." | ".$_account['ident_realname'].' '.' <'.$_account['ident_email'].'>'; $name[] = $_account['ident_org']." | ".$_account['ident_realname'].($_fullString ? ' '.' <'.$_account['ident_email'].'>' : '');
} }
if ($identLabel & self::IDENT_EMAIL || empty($name)) if ($identLabel & self::IDENT_EMAIL || empty($name))
{ {
if (strpos($_account['ident_email'], '@') !== false || trim($_account['ident_email']) !='') if ($_fullString && (strpos($_account['ident_email'], '@') !== false || trim($_account['ident_email']) !=''))
{ {
$name[] = ' <'.$_account['ident_email'].'>'; $name[] = ' <'.$_account['ident_email'].'>';
} }