Sending Email in .NET: SMTP with MailKit, TLS and Ports, Local Testing with Mailpit and the State of SmtpClient
In new .NET projects send email with MailKit rather than System.Net.Mail.SmtpClient: use StartTls on 587 and SslOnConnect on 465, avoid Auto, reuse the connection and read the password from a secret. We send Bookstore's order confirmation with HTML, plain text, an inline logo and an attached invoice to a STARTTLS Mailpit and show the MIME structure and the up to sixfold connection gap over 50 emails with real output.
15 Nov 2026
·
12 min
·
7