- /* already set */
- if (account->flags & M_ACCT_LOGIN)
- return 0;
-#ifdef USE_IMAP
- else if (account->type == M_ACCT_TYPE_IMAP)
- {
- if (ImapLogin)
- strfcpy (account->login, ImapLogin, sizeof (account->login));
- else
- strfcpy (account->login, ImapUser, sizeof (account->login));
- }
-#endif
+ /* already set */
+ if (account->flags & M_ACCT_LOGIN)
+ return 0;
+ else if (account->type == M_ACCT_TYPE_IMAP)
+ {
+ if (!m_strisempty(ImapLogin)) {
+ m_strcpy(account->login, sizeof(account->login), ImapLogin);
+ account->flags |= M_ACCT_LOGIN;
+ }
+ }
+
+ if (!(account->flags & M_ACCT_LOGIN)) {
+ mutt_account_getuser (account);
+ m_strcpy(account->login, sizeof(account->login), account->user);
+ }
+
+ account->flags |= M_ACCT_LOGIN;