IMAP does not work. Authentisation fAILS

IMAP does not work anymore. SMTP works fine, webmail and mobile email works fine as well. Data base was full so I removed many mails locally but the synchronisation does not happen since the server rejects the IMAP. Repair and Fix did not resolve the error. The following message is documented.
14:53:59 [email protected] [IMAP] MailClient.Accounts.ConnectionException: This operation is only allowed using a successfully authenticated context.
—> System.InvalidOperationException: This operation is only allowed using a successfully authenticated context.
at MailClient.Authentication.Mechanisms.NegotiateMechanism.Client.EvaluateChallenge(Byte challenge)
at MailClient.Imap.Base.Connection.AuthenticateAsync(SaslMechanism scheme, ClientCredential credential, Boolean useInitialResponse, CancellationToken cancellationToken)
at MailClient.Protocols.Imap.ConnectionPoolEntry.ConnectInternalAsync(CancellationToken cancellationToken)
— End of inner exception stack trace —
at MailClient.Protocols.Imap.ConnectionPoolEntry.ConnectInternalAsync(CancellationToken cancellationToken)
at MailClient.Protocols.Imap.ConnectionPool.AcquireConnectionAsync(Folder mailFolder, Boolean noSelect)
at MailClient.Protocols.Imap.ConnectionContext.CreateContextAsync(ImapAccount account, Folder folder, Boolean noSelect)
at MailClient.Protocols.Imap.ImapMailSynchronizer.AppendAsync(IItemUploadContext1 uploadContext, FolderInfo info, UploadItem item, CancellationToken cancellationToken) at MailClient.Protocols.Imap.ImapMailSynchronizer.UploadAsync(IItemUploadContext1 uploadContext, Folder folder, IEnumerable1 items, CancellationToken cancellationToken) at MailClient.Protocols.Imap.ImapMailSynchronizer.Upload(IItemUploadContext1 uploadContext, Folder folder, IEnumerable1 items, CancellationToken cancellationToken) at MailClient.Protocols.Common.ItemSynchronizer2.<>c__DisplayClass35_0.b__0(WorkerStatus status, CancellationToken cancellationToken)
at MailClient.Protocols.Imap.ImapActionCommand.ExecuteInternalSync(WorkerStatus status)
at MailClient.Protocols.Imap.ImapActionCommand.Execute(WorkerStatus status)
at MailClient.Commands.Command.Process(WorkerStatus status)
AccountId = (removed)
AccountName = (removed)
IMAP_SERVER_TYPE = Outlook
RunInPlace = False

       EnqueuedStackTrace =
            at MailClient.Protocols.Common.ItemSynchronizer`2.EnqueueUpload(Folder folder, IEnumerable`1 items, Action`1 completed, CancellationToken cancellationToken)
            at MailClient.Protocols.Common.ItemSynchronizer`2.GoOnline()
            at MailClient.Protocols.Imap.ImapMailSynchronizer.GoOnline()
            at MailClient.Protocols.Imap.ImapAccount.GoOnlineInt()
            at MailClient.Protocols.Common.AccountBase.ChangeOnlineState(Boolean online, OfflineReason offlineReason)
            at MailClient.Protocols.Common.AccountBase.GoOnline()
            at System.Threading.Tasks.Parallel.<>c__DisplayClass43_0`2.<PartitionerForEachWorker>b__1(IEnumerator& partitionState, Int64 timeout, Boolean& replicationDelegateYieldedBeforeCompletion)
            at System.Threading.Tasks.TaskReplicator.Replica.Execute()
            at System.Threading.Tasks.Task.InnerInvoke()
            at System.Threading.Tasks.Task.<>c.<.cctor>b__281_0(Object obj)
            at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state)
            at System.Threading.Tasks.Task.ExecuteWithThreadLocal(Task& currentTaskSlot, Thread threadPoolThread)
            at System.Threading.Tasks.ThreadPoolTaskScheduler.TryExecuteTaskInline(Task task, Boolean taskWasPreviouslyQueued)
            at System.Threading.Tasks.TaskScheduler.TryRunInline(Task task, Boolean taskWasPreviouslyQueued)
            at System.Threading.Tasks.Task.InternalRunSynchronously(TaskScheduler scheduler, Boolean waitForCompletion)
            at System.Threading.Tasks.TaskReplicator.Run[TState](ReplicatableUserAction`1 action, ParallelOptions options, Boolean stopOnFirstFailure)
            at System.Threading.Tasks.Parallel.PartitionerForEachWorker[TSource,TLocal](Partitioner`1 source, ParallelOptions parallelOptions, Action`1 simpleBody, Action`2 bodyWithState, Action`3 bodyWithStateAndIndex, Func`4 bodyWithStateAndLocal, Func`5 bodyWithEverything, Func`1 localInit, Action`1 localFinally)
            at System.Threading.Tasks.Parallel.ForEachWorker[TSource,TLocal](IEnumerable`1 source, ParallelOptions parallelOptions, Action`1 body, Action`2 bodyWithState, Action`3 bodyWithStateAndIndex, Func`4 bodyWithStateAndLocal, Func`5 bodyWithEverything, Func`1 localInit, Action`1 localFinally)
            at System.Threading.Tasks.Parallel.ForEach[TSource](IEnumerable`1 source, Action`1 body)
            at MailClient.Accounts.AccountList.SetOnlineState(Boolean online, OfflineReason offlineReason, IComparer`1 comparer)
            at MailClient.Accounts.BindingAccountBase.GoOnline()
            at System.Threading.Tasks.Parallel.<>c__DisplayClass43_0`2.<PartitionerForEachWorker>b__1(IEnumerator& partitionState, Int64 timeout, Boolean& replicationDelegateYieldedBeforeCompletion)
            at System.Threading.Tasks.TaskReplicator.Replica.Execute()
            at System.Threading.Tasks.Task.InnerInvoke()
            at System.Threading.Tasks.Task.<>c.<.cctor>b__281_0(Object obj)
            at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state)
            at System.Threading.Tasks.Task.ExecuteWithThreadLocal(Task& currentTaskSlot, Thread threadPoolThread)
            at System.Threading.Tasks.ThreadPoolTaskScheduler.TryExecuteTaskInline(Task task, Boolean taskWasPreviouslyQueued)
            at System.Threading.Tasks.TaskScheduler.TryRunInline(Task task, Boolean taskWasPreviouslyQueued)
            at System.Threading.Tasks.Task.InternalRunSynchronously(TaskScheduler scheduler, Boolean waitForCompletion)
            at System.Threading.Tasks.TaskReplicator.Run[TState](ReplicatableUserAction`1 action, ParallelOptions options, Boolean stopOnFirstFailure)
            at System.Threading.Tasks.Parallel.PartitionerForEachWorker[TSource,TLocal](Partitioner`1 source, ParallelOptions parallelOptions, Action`1 simpleBody, Action`2 bodyWithState, Action`3 bodyWithStateAndIndex, Func`4 bodyWithStateAndLocal, Func`5 bodyWithEverything, Func`1 localInit, Action`1 localFinally)
            at System.Threading.Tasks.Parallel.ForEachWorker[TSource,TLocal](IEnumerable`1 source, ParallelOptions parallelOptions, Action`1 body, Action`2 bodyWithState, Action`3 bodyWithStateAndIndex, Func`4 bodyWithStateAndLocal, Func`5 bodyWithEverything, Func`1 localInit, Action`1 localFinally)
            at System.Threading.Tasks.Parallel.ForEach[TSource](IEnumerable`1 source, Action`1 body)
            at MailClient.Accounts.AccountList.SetOnlineState(Boolean online, OfflineReason offlineReason, IComparer`1 comparer)
            at MailClient.Accounts.AccountManager.SetOnlineState(Boolean toOnline, OfflineReason offlineReason)
            at MailClient.Accounts.DesktopAccountManager.SetOnlineState(Boolean toOnline, OfflineReason offlineReason)
            at MailClient.Accounts.AccountManager.set_UserOnline(Boolean value)
            at MailClient.UI.Forms.formMain.sendReceiveAll()
            at MailClient.UI.Forms.formMain.stripButton_Refresh_Click(Object sender, EventArgs e)
            at System.Windows.Forms.Control.OnClick(EventArgs e)
            at MailClient.Common.UI.Controls.ControlToolStrip.ControlToolStripButton.PerformClick()
            at MailClient.Common.UI.Controls.ControlToolStrip.ControlToolStripButton.OnMouseUp(MouseEventArgs e)
            at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)
            at System.Windows.Forms.Control.WndProc(Message& m)
            at MailClient.Common.UI.Controls.AutomationViewUserControl.WndProc(Message& m)
            at System.Windows.Forms.NativeWindow.Callback(HWND hWnd, MessageId msg, WPARAM wparam, LPARAM lparam)
            at Windows.Win32.PInvoke.DispatchMessage(MSG* lpMsg)
            at System.Windows.Forms.Application.ComponentManager.Microsoft.Office.IMsoComponentManager.FPushMessageLoop(UIntPtr dwComponentID, msoloop uReason, Void* pvLoopData)
            at System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(msoloop reason, ApplicationContext context)
            at System.Windows.Forms.Application.ThreadContext.RunMessageLoop(msoloop reason, ApplicationContext context)
            at System.Windows.Forms.Application.Run(ApplicationContext context)
            at MailClient.Program.<>c.<Main>b__205_3()
            at System.Windows.Forms.Control.InvokeMarshaledCallbackDo(ThreadMethodEntry tme)
            at System.Windows.Forms.Control.InvokeMarshaledCallbackHelper(Object obj)
            at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state)
            at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
            at System.Windows.Forms.Control.InvokeMarshaledCallback(ThreadMethodEntry tme)
            at System.Windows.Forms.Control.InvokeMarshaledCallbacks()
            at System.Windows.Forms.Control.WndProc(Message& m)
            at System.Windows.Forms.ScrollableControl.WndProc(Message& m)
            at System.Windows.Forms.ContainerControl.WndProc(Message& m)
            at System.Windows.Forms.Form.WndProc(Message& m)
            at MailClient.Common.UI.Forms.BaseForm.WndProc(Message& m)
            at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
            at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
            at System.Windows.Forms.NativeWindow.Callback(HWND hWnd, MessageId msg, WPARAM wparam, LPARAM lparam)
            at Xilium.CefGlue.Interop.libcef.run_message_loop()
            at MailClient.Program.Main(String[] args)
       GUIStatus_Exception_Reported = True

As repairing your IMAP account did not fix it, then as its an IMAP account suggest to go to “Menu / Accounts” and “remove and re-add your account” via either using the automatic account wizard or manual option depending on what your server supports. That normally fixes account problems if its eg: the account has become possibly corrupted in some way.

If you still get the same problem, then update “who your mailbox provider is”, and what your IMAP Incoming mail “Server Address”, “Port”, and “Security Policy” are, so we can check them.

Also update what version of eM Client you are using, and if you have Windows or Mac and OS version.

Lastly if you have only suddenly just start getting IMAP connection problems and you haven’t changed any IMAP settings recently, sometimes that can be related to eg: Optionally installed firewall / security programs, or optionally installed Antivirus programs, or VPN’s that might have updated causing receiving connection problem. So if you have anything like that installed “other than what comes default with the OS”, then try completely disabling those to test.

Microsoft has been migrating Hotmail/Live/Outlook.com accounts from basic authentication for login (username and password) to requiring OAUTH2. Em Client supports OAUTH2. However, it was a year after Microsoft made the announcement before they hit my account. The only way to get the account defined within eM Client to use OAUTH2 was to delete the account, and recreate a new account just like the old one.

During the OAUTH2 validation process, the client connects to the server whereupon you see a web page at the site asking for your login credentials to prove it is you wanting to use OAUTH2 in a client. The OAUTH server then doles out a token (and, I think, a renewal token) to use thereafter for OAUTH2 login. The client no longer uses username and password, just the token. The token expires, but the client is supposed to use the renewal token to get another OAUTH2 token without user intervention. I’ve seen clients that neglect to renew before the token expires, so they have to get a new token. How that is done depends on how the client is configured to negotiate for a new token. In Thunderbird, I think you delete the saved login data for the server in Tbird’s password store. However, because the client needs a new token, the whole process repeats where the client connects the web site to have it verify you are allowed access for that client for the server to give the client a token to use thereafter. There is no function in eM Client to negotiate for a new token. You have to delete the account, and recreate the account but using OAUTH2.

When an account defined in eM Client is using OAUTH2 tokens, you won’t see login credentials in the account definition anymore. When OAUTH2 is used, going into the IMAP or SMTP tab in an account definition does not show username and password fields to enter that data, because it isn’t being used anymore. Most clients don’t show token info, like domain, expiration, or whatever is in the token or associated with it.

You might’ve been hit by Microsoft switching your account from basic auth to OAUTH2. Could be the token expired, and eM Client didn’t negotiate getting a new one. Try deleting the IMAP account, and recreating it, but specify using OAUTH2 on the recreate (if eM Client doesn’t do it automatically). It would be nice if there were a more elegant (less cumbersome) method of getting eM Client to get a new OAUTH2 token, but I don’t see the option.

Since this is an IMAP account, when you create a new account in eM Client to point at the same server and account as for the old account that was in eM Client, the client mirrors what is on the server, and you’re back to where you were.

I was adviced by provider and you to delete the account and then recreate the same account. I did that with no effect. I changed the password so I could see that mobile client and web client worked again after the password change. So did SMTP but still not IMAP. I have used the same settings for several years without problems so something new has happened.
My provider is imap.fsdata.se, port 993 and SSL. I run Windows 10 with latest version of eMClient.

I have used the same settings for several years without problems so something new has happened.

My provider is imap.fsdata.se, port 993 and SSL. I run Windows 10 with latest version of eMClient

When you add the account either using the automatic account wizard or via the manual add account option, do you get any errors ? Or does it complete the account setup ok.

Also is your IMAP Security Policy "Use SSL/TLS on special port legacy as per below ?

1000004080

I used manual setup to be able to choose port and other settings. Yes security was as you stated. No I cannot recall any error message on setup until I tried IMAP. I used authorisation data for IMAP which did not work. For SMTP everything worked OK so I conclude the setup was OK.

This is the log result when the authorisation fails
11:48:37 [email protected] IMAP Synkroniserar mapplista
11:48:38 [email protected] [IMAP] MailClient.Accounts.ConnectionException: This operation is only allowed using a successfully authenticated context.
—> System.InvalidOperationException: This operation is only allowed using a successfully authenticated context.
at System.Net.Security.NegotiateAuthentication.GetOutgoingBlob(ReadOnlySpan`1 incomingBlob, NegotiateAuthenticationStatusCode& statusCode)
at MailClient.Authentication.Mechanisms.NegotiateMechanism.Client.EvaluateChallenge(Byte challenge)
at MailClient.Imap.Base.Connection.AuthenticateAsync(SaslMechanism scheme, ClientCredential credential, Boolean useInitialResponse, CancellationToken cancellationToken)
at MailClient.Protocols.Imap.ConnectionPoolEntry.ConnectInternalAsync(CancellationToken cancellationToken)
— End of inner exception stack trace —

[IMAP] MailClient.Accounts.ConnectionException: This operation is only allowed using a successfully authenticated context.
—> System.InvalidOperationException: This operation is only allowed using a successfully authenticated context.

Ok those errors might be referring to the Security Policy in the accounts setup, but if Port 993 and Security Policy "Use SSL/TLS on special port (Legacy) used to work “as you advised”, then that should still be correct in eM Client. Hopefully someone else on this community forum might be able to help with that.

If you have a current active eM Client Pro or Personal paid account, suggest to login to the following eM Client VIP support page below and submit a ticket for this issue.

https://support.emclient.com/