DEV Community πŸ‘©β€πŸ’»πŸ‘¨β€πŸ’»

Joe Enos
Joe Enos

Posted on

Send email with MailKit in .NET

.NET Framework used to use SmtpClient, which read this from the app.config/web.config file:

<mailSettings>
    <smtp deliveryMethod="Network">
      <network host="my-host" 
               port="587" 
               userName="my-user"
               password="my-password" 
               enableSsl="true"
               defaultCredentials="false" 
      />
    </smtp>
</mailSettings>
Enter fullscreen mode Exit fullscreen mode

Microsoft has deprecated SmtpClient, and they recommend a library like MailKit.

MailKit is a little more verbose than the old way, but it's still reasonably straightforward. Here's how to use it:

Top comments (0)

⬇️ The only reason people scroll to the bottom...

Β 

is because they want to read more. Sign up for an account to bookmark, comment, and react to articles that interest you.