Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What could be reasons that Microsoft retired SmtpClient? [closed]

In .NET Framework 4.7 doc, Microsoft marked SmtpClient obsolete with the following reason:

SmtpClient and its network of types are poorly designed, we strongly recommend you use https://github.com/jstedfast/MailKit and https://github.com/jstedfast/MimeKit instead

I am curious and no expert in this area. What could be this "poorly designed" that MS had to recommend an outside library instead? How bad it is for projects that still use it?

like image 467
Luke Vo Avatar asked Jun 04 '18 15:06

Luke Vo


1 Answers

SmtpClient does not supports DKIM (or SPF) authentication. It does not send naturally RSA keys and some mail providers consider the key less than 1024bits as spam like gmail or orange.

Check the "A message I sent from my domain wasn't authenticated" paragraph here.

I recently changed my implementation too, and i advise MailKit : the code definition is pretty much the same (allow you to keep a MailMessage object), and it works very well !

using (var client = new MailKit.Net.Smtp.SmtpClient())
{
      client.Connect(Host, Port, UseSsl);
      client.Authenticate(Credential.UserName, Credential.Password);
      client.Send(MimeMessage.CreateFromMailMessage(new MailMessage()));
      client.Disconnect(true);
}
like image 94
GGO Avatar answered Nov 01 '22 11:11

GGO