Probably the most difficult bit of setting up an email service is the SMTP server settings. This project features a
demonstrates error emails from the Error page and exception emails with the ExceptionEmailerMiddleware.
The 5th article I published over 2 1/2 years ago,
ASP.NET Core 2.2 - SMTP EmailSender Implementation, is still one of my most popular articles.
I published the
ASP.NET Core 3.1 - SMTP EmailSender article over a year ago. I have updated KenHaggerty.Com with
new EmailSettings and EmailSender. This free project and article series will review and update the processes and
add a couple of enhancements.
In the research projects which send emails, the EmailSettings properties have grown to implement a customizable
html banner. KenHaggerty.Com and projects which implement AesCrypto added a PasswordEncrypted property.
Developing and testing the SMTP Settings Tester has combined and refined the EmailSettings. This article reviews
adding the TOpions of EmailSettings to the ServiceCollection with the Configuration. GetSection("EmailSettings").
One of the best reasons to use the runtime TOpions of EmailSettings is User Secrets. I use the same secrets. json
configuration for the development of multiple projects. I manage different User Secrets configurations by naming them
with a friendly name and last update date. This article will demonstrate applying, naming, and sharing User Secrets.
I developed a AesCrypto class and an AES Cipher demo to encrypt and decrypt SQL Server connection strings.
KenHaggerty.Com and projects which implement AesCrypto can also encrypt and decrypt email account passwords.
The SMTP Settings Tester Project does not require SQL Server but includes an empty ApplicationDbContext and
an encrypted DefaultConnection in appsettings to demonstrate encryption for SQL Server ConnectionStrings.
This article will describe email account passwords and connection string encryption.
The EmailSender injects the runtime EmailSettings and sends an email to the provided address using a html
template or a text only message email with HttpContext details like User-Agent, anonymized IP address, Path,
and QueryString to the AdminEmail property. This article will describe the new EmailSender which implements
a html template with a customizable banner, a ServerCertificateValidationCallback delegate, new MailKit. Net.
Smtp client asynchronous methods, and a MailKit. Security. SecureSocketOptions. Auto option which allows
the MailKit. IMailService decide which SSL or TLS options to use (default). If the server does not support SSL
or TLS, then the connection will continue without any encryption.
SMTP Settings Tester
The SMTP Settings Tester reads the runtime EmailSettings and the EmailSettings from appsettings. json and
appsettings. development. json. All EmailSettings discovered can be loaded into a generator and modified to
test custom settings, runtime settings are loaded by default. The SMTP Settings Tester sends an email with the
functional EmailSettings to the AdminEmail or the SupportEmail using a html template. A message is displayed
after each send attempt. A success message if the email is sent or a message with error details when the attempt
is not completed.