email_verification 1.1.0
See the version list below for details.
dotnet add package email_verification --version 1.1.0
NuGet\Install-Package email_verification -Version 1.1.0
<PackageReference Include="email_verification" Version="1.1.0" />
paket add email_verification --version 1.1.0
#r "nuget: email_verification, 1.1.0"
// Install email_verification as a Cake Addin #addin nuget:?package=email_verification&version=1.1.0 // Install email_verification as a Cake Tool #tool nuget:?package=email_verification&version=1.1.0
Email Validation Library
This C# library allows you to validate email addresses, send verification emails, and confirm registered email addresses in a database.
Prerequisites
- .NET version >= 2.1
Features
- Email address validation: Verify if an email address is in a valid format.
- Sending verification emails: Send a verification email with a validation code to a given email address.
- Email address confirmation: Verify the validation code submitted by the user and confirm the email address if the code is valid and not expired.
- Get the Validation Status
Usage
Configuration
Before using the library, you need to configure the SQL Server database connection string and specify the table name used to store email addresses and validation codes. You can do this by setting the static properties ConnectionString
and TableName
of the EmailValidator
class. For example:
EmailValidator.ConnectionString = "YourConnectionString";
EmailValidator.TableName = "YourTableName";
EmailValidator.ExpirationCodeTime = 15; // in minutes
- The default table name is ValidationEmails, and the default code expiration time ExpirationCodeTime is 15 minutes.
Email Address Validation
To validate an email address, simply call the static method ValidateEmail
of the EmailValidator class
. For example:
bool isValid = EmailValidator.ValidateEmail("test@example.com");
Sending Verification Email
To send a verification email with a validation code, call the static method SendMailVerification
of the EmailValidator class
. Make sure to provide the required SMTP credentials in the CredentialModel
object. For example:
CredentialModel credential = new CredentialModel
{
Name = "YourCompany",
Email = "your-email@example.com",
Host = "smtp.example.com",
Port = 587,
Password = "YourPassword"
};
string emailTo = "test@example.com";
string linkRedirect = "https://yoursite.com/confirmation-email";
EmailResponse response = EmailValidator.SendMailVerification(emailTo, credential, linkRedirect);
if (response.IsValid)
{
// The validation code has been successfully sent and stored in the database.
}
else
{
// An error occurred while sending the email.
// Display the error message from the response.
Console.WriteLine(response.Message);
}
Email Address Confirmation
To confirm an email address using the received validation code, call the static method ConfirmMail
of the EmailValidator class
. For example:
string emailToConfirm = "test@example.com";
string validationCode = "ABC123";
ConfirmEmailResponse confirmResponse = EmailValidator.ConfirmMail(emailToConfirm, validationCode);
if (confirmResponse.IsConfirmed)
{
// The email address has been successfully confirmed.
// The database has been updated to mark the email address as confirmed.
}
else
{
// An error occurred while confirming the email address.
// Display the error message from the response.
Console.WriteLine(confirmResponse.Message);
}
Disclaimer
Before using this library in production, ensure that you have properly configured your database and SMTP server for email delivery. Use secure configuration settings for credentials and avoid storing passwords in plaintext.
Acknowledgments
This library uses the "MailKit" and "Microsoft.Data.SqlClient" NuGet packages for email and database management, respectively. We thank the developers of these packages for their excellent work.
Contributors
License
This library is distributed under the MIT License.
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net5.0 was computed. net5.0-windows was computed. net6.0 was computed. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 was computed. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. |
.NET Core | netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
.NET Standard | netstandard2.1 is compatible. |
MonoAndroid | monoandroid was computed. |
MonoMac | monomac was computed. |
MonoTouch | monotouch was computed. |
Tizen | tizen60 was computed. |
Xamarin.iOS | xamarinios was computed. |
Xamarin.Mac | xamarinmac was computed. |
Xamarin.TVOS | xamarintvos was computed. |
Xamarin.WatchOS | xamarinwatchos was computed. |
-
.NETStandard 2.1
- System.Data.SqlClient (>= 4.8.6)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.