MailKit: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond.

I get the following error message when trying to send a simple message:

A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond.

I have a simple console app that’s doing this:

var message = new MimeMessage();
message.To.Add(new MailboxAddress("test", "user@server.com"));
message.From.Add(new MailboxAddress("do-not-reply", "do-not-reply@server.com"));
message.Subject = "TEST";

var mailkitClient = new SmtpClient();
mailkitClient.Connect("smtp.server.net", 25, false);
mailkitClient.Send(message);

It hangs when trying to call Send and comes back with the error message above.

If I use the regulat .NET SmtpClient I have no problems running the following and getting an email:

var smtpClient = new SmtpClient();
smtpClient.Host = "smtp.server.net";
smtpClient.Port = 25;

await smtpClient.SendMailAsync("donotreply@server.com", "user@server.com", "test", "test");

So I don’t believe I have a firewall or port issue. What am I missing?

Trying this from a console app with .NET Core 3.0. Also tried from a .NET Standard 2.0 class library project. Using MailKit 2.3.1.6.

About this issue

  • Original URL
  • State: closed
  • Created 5 years ago
  • Reactions: 1
  • Comments: 21 (11 by maintainers)

Commits related to this issue

Most upvoted comments

2.20 worked

AND

the following worked on Mailkit 2.3.1.6 as well!

mailkitClient.Capabilities &= ~SmtpCapabilities.Chunking;
mailkitClient.Capabilities &= ~SmtpCapabilities.BinaryMime;

much mahalo!