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?
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);
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With