Mailkit: IMAP connect error: syntax error / forbids use of this system for unsolicited....

Created on 13 Nov 2020  路  2Comments  路  Source: jstedfast/MailKit

I'm trying to connect to a Rackspace IMAP server using the following code.

using (var client = new ImapClient(new ProtocolLogger(logfile)))
{
    client.Connect(account.Server, 587, SecureSocketOptions.StartTls);
    client.Authenticate(account.Username, `account.Password);

I get an error:
Syntax error in IMAP server greeting. Unexpected token: [atom: 220]

The log file reads:

_Connected to imap://fakemailserver.com:587/?starttls=always
S: 220 fakemailserver.com ESMTP - VA Code Section 18.2-152.3:1 forbids use of this system for unsolicited bulk electronic mail (Spam)_

Note: I currently connect to this server successfully with MailSystem.NET library. I'm trying to switch over.

How do I resolve this?

question

Most helpful comment

Thank you.

As a side note, the consistent responses from you seen on different forums, plus the detailed errors and documentation
provided makes this library a pleasure to work with.
Thanks.

All 2 comments

You are trying to use the ImapClient to connect to an SMTP port.

Either use an SmtpClient or connect to an IMAP port (143 or 993).

Thank you.

As a side note, the consistent responses from you seen on different forums, plus the detailed errors and documentation
provided makes this library a pleasure to work with.
Thanks.

Was this page helpful?
0 / 5 - 0 ratings