Search code examples
c#.netmailkit.net-4.8system.net.mail

Which library to use for sending email in c#?


I am learning c# .I want to send an autogenerated email to user.

Initially, I thought of using System.Net.Mail for that, but while checking under SMTPClient Page Microsoft doc had mentioned to use Mailkit library instead.

So, I am confused whether to implement using System.net.mail or using open source library like Mailkit..and what is the difference between them. Could anyone pls explain in detail. Or need to use both of them while code implementation.

Note: My application uses C# (.Net framework 4.8)


Solution

  • System.Net.Mail has been deprecated and you should use the recomendation from Microsoft: Mailkit

    Also read: https://learn.microsoft.com/pt-br/dotnet/api/system.net.mail.smtpclient?view=net-6.0

    We don't recommend that you use the SmtpClient class for new development because SmtpClient doesn't support many modern protocols. Use MailKit or other libraries instead. For more information, see SmtpClient shouldn't be used on GitHub.