From 6c102be383c03520a4353e45f8fe7196e6828996 Mon Sep 17 00:00:00 2001 From: Hadi Nategh Date: Wed, 5 Jul 2017 17:41:31 +0200 Subject: [PATCH] * Mail: Fix preferred identity in compose dialog never get selected --- mail/inc/class.mail_compose.inc.php | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/mail/inc/class.mail_compose.inc.php b/mail/inc/class.mail_compose.inc.php index 5344dc036f..75bec46226 100644 --- a/mail/inc/class.mail_compose.inc.php +++ b/mail/inc/class.mail_compose.inc.php @@ -1332,7 +1332,21 @@ class mail_compose $etpl->setElementAttribute('folder','autocomplete_params',array('mailaccount'=>$content['mailaccount'])); // join again mailaccount and identity $content['mailaccount'] .= ':'.$content['mailidentity']; + //Try to set the initial selected account to the first identity match found + // which fixes the issue of prefered identity never get selected. + if (!in_array($content['mailaccount'], array_keys($sel_options['mailaccount']))) + { + foreach ($sel_options['mailaccount'] as $ident => $value) + { + $idnt_acc_parts = explode(':', $ident); + if ($content['mailidentity'] == $idnt_acc_parts[1]) + { + $content['mailaccount'] = $ident; + break; + } + } + } // Resolve distribution list before send content to client foreach(array('to', 'cc', 'bcc', 'replyto') as $f) {