.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>
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: