jstedfast/MailKit

SmtpProtocolException - Last Smtp Response before failure

tinohager opened this issue · 6 comments

Describe the solution you'd like

I try to send a mail but the ip is blocked by Spamhaus, in my case it is a dynamic ip from my private internet access.
It would be important for me to receive the smtp response I got. Which then triggers the SmtpProtocolException is this possible?

The exception.Message not contains 550 5.7.1 Service unavailable, Client host [123.123.123.123] blocked using Spamhaus. it contains The SMTP server has unexpectedly disconnected.

throw new SmtpProtocolException ("The SMTP server has unexpectedly disconnected.");

C: MAIL FROM:<sender@domain.com> SIZE=1618
C: RCPT TO:<recipient@domain.net>
S: 550 5.7.1 Service unavailable, Client host [123.123.123.123] blocked using Spamhaus.

Yes, if you disable the PIPELINE extension, you'll get that response in the exception message.

client.Capabilities &= ~SmtpCapabilities.Pipelining;

Add that code before sending the message.

I just released MailKit v4.5.0 with the fix for this.

many thanks for the customization

Yes, if you disable the PIPELINE extension, you'll get that response in the exception message.

client.Capabilities &= ~SmtpCapabilities.Pipelining;

Add that code before sending the message.

Unfortunately, this solution does not work, the SmtpProtocolException is still triggered

I just released MailKit v4.5.0 with the fix for this.

I would like to see the last smtp error message available as a field. Instead of mixing a text block from the library with the smtp error code. If someone wants to search for the error they will find nothing in the requested part. I could of course build a logic that removes the first part but I would find that unattractive. 😞

Unfortunately, this solution does not work, the SmtpProtocolException is still triggered

I know, but it would get you the response message.