ASP.NET Core 5.0 - SMTP Settings Tester Project

This article introduces a series about the implementation of a SMTP email service. I will assume you have downloaded the ASP.NET Core 5.0 - SMTP Settings Tester Project. Registered users can download the source code for free at Manage > Assets.

SMTP Settings Tester Project and Article Series

This project implements Bootstrap v5, Bootstrap Native, and the KenHaggerty. Com. SingleUser NuGet package which provides log in and log out pages for a single user to access the Admin pages. jQuery has been removed. I created a topic, ASP.NET Core 5.0 - SMTP Settings Tester Project for discussions. More details and screenshots at ASP.NET Core 5.0 - SMTP Settings Tester Project. The details page includes the version change log.

Probably the most difficult bit of setting up an email service is the SMTP server settings. This project features a sample Privacy Policy, AesCrypto, EmailSettings, EmailSender, and an SMTP Settings Tester. The project 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.

New EmailSettings

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").

User Secrets

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.

AppSettings Encryption

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.

EmailSender Service

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.

SMTP Settings Tester.
SMTP Settings Tester Mobile.
Ken Haggerty
Created 08/02/21
Updated 08/07/21 01:18 GMT

Log In or Reset Quota to read more.

Article Tags:

Email Json Model Validation
Successfully completed. Thank you for contributing.
Contribute to enjoy content without advertisments.
Something went wrong. Please try again.



Not accepting new comments.

Submit your comment. Comments are moderated.

User Image.
DisplayedName - Member Since ?