Avoid duplicating from email address when generating identity

This commit is contained in:
Hadi Nategh 2022-01-10 14:03:14 +01:00
parent 0748db0c70
commit d67b0b1e66
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'];
// Try to fix identity email with no domain part set
$_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-Mailer', 'EGroupware-Mail');

View File

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