I'm trying to use MimeKit and MailKit to fetch e-mail from inbox.
But the logon to the mail server Imap does not work.
I'm using port 993 with ssl.
I have tried to connect/LOGIN/FETCH on port 143 with Telnet and it works.
I have tried to connect/LOGIN/FETCH on port 993 with Openssl and it works.
Mailkit v.1.4.2.1
KODE:
using (var client = new ImapClient(new ProtocolLogger("imap.log")))
{
try
{
client.Connect(server, this.port, true);
client.AuthenticationMechanisms.Remove("XOAUTH2");
client.Authenticate(user, password);
var inbox = client.Inbox;
inbox.Open(FolderAccess.ReadWrite);
if (inbox.Count > 0)
{
var range = Enumerable.Range(0, inbox.Count).ToArray();
inbox.AddFlags(range, MessageFlags.Deleted, false);
inbox.Expunge();
}
client.Disconnect(true);
}
catch (AuthenticationException e)
{
throw e;
}
}
IMAP.LOG:
Connected to imaps://xxxx.xxx.xx:993/
S: * OK The Microsoft Exchange IMAP4 service is ready.
C: A00000000 CAPABILITY
S: * CAPABILITY IMAP4 IMAP4rev1 AUTH=PLAIN AUTH=NTLM AUTH=GSSAPI UIDPLUS MOVE ID CHILDREN IDLE NAMESPACE LITERAL+
S: A00000000 OK CAPABILITY completed.
C: A00000001 AUTHENTICATE NTLM
S: +
C: TlRMTVNTUAABAAAABwIIAAAAAAAgAAAAAAAAACAAAAA=
S: +
TlRMTVNTUAACAAAABgAGADgAAAAFAokCETTDB74D2YsAAAAAAAAAAKIAogA+AAAABgLwIwAAAA9LAE0ARAACAAYASwBNAEQAAQAUAEsATQBEAEUAWABDADIAMAAwADYABAAaAGkAbgB0AGUAcgBuAC4AawBtAGQALgBkAGsAAwAwAEsATQBEAEUAWABDADIAMAAwADYALgBpAG4AdABlAHIAbgAuAGsAbQBkAC4AZABrAAUAGgBpAG4AdABlAHIAbgAuAGsAbQBkAC4AZABrAAcACAA8TRLTaRLSAQAAAAA=
C: TlRMTVNTUAADAAAAGAAYAFYAAAAYABgAbgAAAAAAAABIAAAADgAOAEgAAAAAAAAAVgAAAAAAAACGAAAAAYIIAgoAWikAAAAPaQBvAG0AdABlAHMAdAA6stwc8LXYfAAAAAAAAAAAAAAAAAAAAAC5L0RCGGq9hCGwriyfURwGscjNCDTBeSA=
S: A00000001 NO AUTHENTICATE failed.
C: A00000002 AUTHENTICATE PLAIN
S: +
C: XXXXXXXXXX
S: A00000002 NO AUTHENTICATE failed.
C: A00000003 LOGIN xxxxxxxxx xxxxxxxx
S: A00000003 NO Server Unavailable. 15
S: * BYE Connection closed. 14A
Exception:
AuthenticationException: “Authentication failed.”
at MailKit.Net.Imap.ImapClient.Authenticate(Encoding encoding, ICredentials credentials, CancellationToken cancellationToken)
at MailKit.MailService.Authenticate(String userName, String password, CancellationToken cancellationToken)