Jasmin.SimpleSMTP
2.1.11
dotnet add package Jasmin.SimpleSMTP --version 2.1.11
NuGet\Install-Package Jasmin.SimpleSMTP -Version 2.1.11
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Jasmin.SimpleSMTP" Version="2.1.11" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Jasmin.SimpleSMTP --version 2.1.11
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: Jasmin.SimpleSMTP, 2.1.11"
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install Jasmin.SimpleSMTP as a Cake Addin #addin nuget:?package=Jasmin.SimpleSMTP&version=2.1.11 // Install Jasmin.SimpleSMTP as a Cake Tool #tool nuget:?package=Jasmin.SimpleSMTP&version=2.1.11
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
Simple (SMTP - Simple Mail Transfer Protocol)
Mission Statement:
- Hide or Eliminate the complexity of the SMTP Protocol
License
Version Features:
- smtpSetting.Host.SecureSocketOption = SecureSocketOption.StartTlsWhenAvailable; // As the default
- smtpSetting.Host.Authenticate = true; // As the default
Previous version assumed
the above while this version exposes the properties
Usage/C# Examples
This main method contains the basic steps in order to send an email
- Know what you want to mail and to whom
- know the SMTP server's configuration that you will use to send the email
- Send the email using this SendEmailAsync method
using SimpleSmtp.Class.Models.MailRequests;
using SimpleSmtp.Class.Models.SmtpSettings;
using SimpleSmtp.Class.Services.Foundations;
using SimpleSMTP.SecureSocketOptions;
private static void Main( string[] args )
{
var eMailInformation = PrepareEmail();
var smtpInformation = PrepareSmtpSetting();
var emailService = new EmailService(smtpInformation);
emailService.SendEmailAsync(eMailInformation).Wait();
}
This method provides is an example of how to set typical Email information
This method provides examples of specifying such items as:
- Sender Name (pretty name)
- Sender Email Address
- Subject
- Body
- To (n)
- Cc (n)
- Bcc (n)
- attachment (n)
private static MailRequest PrepareEmail()
{
// All Values as sample only and must be changed to what you desire
var mailRequest = new MailRequest();
mailRequest.Sender.DisplayName = "Sue Smith";
mailRequest.Sender.Address = "SueSmith@xyz.com";
mailRequest.Subject = "Email Subject";
mailRequest.Body = "This is the body of the email";
//Decide how you want to present the email (all combinations can be used together or separately)
mailRequest.AddToRecipient("ToSmith@xyz.com", "To Smith"); // Repeat as often as needed with new "To" Recipients
mailRequest.AddCcRecipient("CcSmith@xyz.com", "Cc Smith"); // Repeat as often as needed with new "CC" Recipients
mailRequest.AddBCcRecipient("BlindSmith@xyz.com", "Blind Smith"); // Repeat as often as needed with new "BCC" Recipients
mailRequest.AddFile(
fullPathAndName: $@"\\YourFilePath\YourFileName,WithExtension",
nameWithExtension: $"NameItThisInEmail.WithThisExtension"); // Repeat for as many files as you would like attached to the email
return emailRequest;
}
This method is for you to set your desired SMTP Setting
This is a sample project so consider dependency inversion in your production application.
private static SmtpSetting PrepareSmtpSetting()
{
// All Values as sample only (Adjust to your preferred SMTP server)
var smtp = new SmtpSetting();
smtp.Host.Name = "smtp.xyz.com";
smtp.Host.Port = 587; // This is the default
smtp.Host.SecureSocketOption = SecureSocketOption.StartTlsWhenAvailable; // This is the default
smtp.Host.Authenticate = true; // This is the default
// You must provide below if Server Authenticates
smtp.Host.UserName = "appid@xyz.com";
smtp.Host.Password = "appid!Password1";
return smtp;
}
Feedback
If you have any feedback, please reach out to us at aspado
Authors
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net7.0 is compatible. 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. |
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.