1

I am trying to connect Imap in the localhost, but getting a debug log as below, but the username and passwords are correct. I am able to connect through web interface with the login credentials.

<= '* CAPABILITY IMAP4 IMAP4rev1 AUTH=PLAIN AUTH=XOAUTH2 SASL-IR UIDPLUS ID UNSELECT CHILDREN IDLE NAMESPACE LITERAL+'
<= 'A0 OK CAPABILITY completed.'
=> 'A1 LOGIN "************@*****.com"             "**************"'
<= 'A1 NO LOGIN failed.'


[connection] Ended
[connection] Closed
[connection] Connected to host
<= '* OK The Microsoft Exchange IMAP4 service is ready. [TQBBAFgAUABSADAAMQAwADEAQwBBADAAMAAyADcALgBJAE4ARABQAFIARAAwADEALgBQAFIATwBEAC4ATwBVAFQATABPAE8ASwAuAEMATwBNAA==]'
=> 'A0 CAPABILITY'
<= '* CAPABILITY IMAP4 IMAP4rev1 AUTH=PLAIN AUTH=XOAUTH2 SASL-IR UIDPLUS ID UNSELECT CHILDREN IDLE NAMESPACE LITERAL+'
<= 'A0 OK CAPABILITY completed.'
=> 'A1 LOGIN "************@*****.com"             "**************"'
<= 'A1 NO LOGIN failed.'

Please anyone help me to resolve this, i checked the complete world of stackoverflow, but nobody couldnt fix this. I appreciate if anyone has the solution.

export const imapConfig = {
imap: {
user: process.env.OUTLOOK_USER,
password: '',
host: process.env.OUTLOOK_HOST,
port: Number(process.env.OUTLOOK_PORT || 993),
tls: true,
authTimeout: 25000,
connTimeout: 30000,
keepalive: true,
secure: true,
debug: console.log
tlsOptions: {
rejectUnauthorized: false
servername: process.env.OUTLOOK_HOST
host: process.env.OUTLOOK_HOST
}
}
}
Saravanan
  • 47
  • 1
  • 8
  • It seems like they are almost certainly not correct. Can you examine the working traffic with a packet capture and compare? – tripleee May 19 '22 at 12:48
  • @tripleee, am i doing anything wrong here ? How to capture the working traffic, any idea ? – Saravanan May 19 '22 at 12:58
  • Wireshark is a popular tool for that, but if you are new to the concept, there is going to be quite some learning curve ahead. – tripleee May 19 '22 at 13:07
  • Have you tried another IMAP client? What login methods has your admin enabled? Some disable plain login, and on O365 you may need to use Oauth2. – Max May 19 '22 at 18:33
  • 1
    Outlook, you say. If that's Outlook365, they disabled plain old passwords recently. There are older questions about that. Or read [Microsoft's page about that](https://learn.microsoft.com/en-us/exchange/client-developer/legacy-protocols/how-to-authenticate-an-imap-pop-smtp-application-by-using-oauth). – arnt May 19 '22 at 20:49
  • @arnt, the same code is working fine for different mailbox basically a stage server account with username and password plain to outlook is working. Whereas the one which I am trying to connect with production mailbox to outlook. But it is login failed, though username and password is correct. – Saravanan May 21 '22 at 18:51
  • @Max, may be i have to contact my Admin to get more details about this issue, my step is that. Atleast I get some idea how to troubleshoot this issue. – Saravanan May 21 '22 at 18:55
  • @arnt, It is working fine now. – Saravanan May 27 '22 at 06:26

1 Answers1

0

If you are trying to access outlook emails using imap with basic authentication, so this is now not possible because Microsoft had disabled or depricated the access of outlook emails using username and password. But you can still access emails using imap through username and oauth token.Here is the link given below for better understanding.

https://www.limilabs.com/blog/oauth2-client-credential-flow-office365-exchange-imap-pop3-smtp

  • As it’s currently written, your answer is unclear. Please [edit] to add additional details that will help others understand how this addresses the question asked. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community Jan 25 '23 at 09:51