https://github.com/iowacomputergurus/netcore.utilities.email.smtp
A collection of utility functions making email delivery more accessible for projects. By default supporting Dependency Injection.
https://github.com/iowacomputergurus/netcore.utilities.email.smtp
aspnet-core email hacktoberfest net-core smtp-client
Last synced: 9 days ago
JSON representation
A collection of utility functions making email delivery more accessible for projects. By default supporting Dependency Injection.
- Host: GitHub
- URL: https://github.com/iowacomputergurus/netcore.utilities.email.smtp
- Owner: IowaComputerGurus
- License: mit
- Created: 2019-01-16T08:30:12.000Z (over 6 years ago)
- Default Branch: develop
- Last Pushed: 2024-11-18T05:02:08.000Z (5 months ago)
- Last Synced: 2024-11-18T06:18:24.714Z (5 months ago)
- Topics: aspnet-core, email, hacktoberfest, net-core, smtp-client
- Language: C#
- Homepage:
- Size: 201 KB
- Stars: 5
- Watchers: 4
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Contributing: CONTRIBUTING.md
- Funding: .github/FUNDING.yml
- License: LICENSE
- Code of conduct: CODE_OF_CONDUCT.md
Awesome Lists containing this project
README
# ICG.NetCore.Utilities.Email.Smtp 

This library provides an easy to use implementation of SMTP based email delivery using the MailKit library internally. This abstraction with proper interfaces allows email implementation inside of your project with little effort and easy to manage integration.
This package depends on the ICG.NetCore.Utilities.Email project for template implementation, as well as the IEmailService interface for Dependency Injection
## SonarCloud Analysis
[](https://sonarcloud.io/dashboard?id=IowaComputerGurus_netcore.utilities.email.smtp)
[](https://sonarcloud.io/dashboard?id=IowaComputerGurus_netcore.utilities.email.smtp)
[](https://sonarcloud.io/dashboard?id=IowaComputerGurus_netcore.utilities.email.smtp)
[](https://sonarcloud.io/dashboard?id=IowaComputerGurus_netcore.utilities.email.smtp)## NuGet
 
## Dependencies
The following additional NuGet packages are installed with this extension.* [MailKit](https://github.com/jstedfast/MailKit) - For email delivery
* [ICG NET Core Utilities Email](https://github.com/IowaComputerGurus/netcore.utilities.email) - For Email Template Configuration## Breaking Changes with 4.x
In an effort to standardize our Email libraries a common `IEmailService` interface was introduced, at this time the existing `ISmtpService` was removed.## Usage
### Installation
Standard installation via HuGet Package Manager
``` powershell
Install-Package ICG.NetCore.Utilities.Email.Smtp
```### Setup & Configuration Options
To setup the needed dependency injection items for this library, add the following line in your DI setup.
``` csharp
services.UseIcgNetCoreUtilitiesEmailSmtp(configuration);
```Additionally you must specify the needed configuration elements within your AppSettings.json file
``` json
"SmtpServiceOptions": {
"AdminEmail": "[email protected]",
"AdminName" : "John Smith",
"Server": "test.smtp.com",
"Port": 527,
"UseSsl": true,
"SenderUsername": "MySender",
"SenderPassword": "Password",
"AlwaysTemplateEmails": true,
"AddEnvironmentSuffix": true
},
"EmailTemplateSettings": {
"DefaultTemplatePath": "Template.html",
"AdditionalTemplates": { "SpecialTemplate": "File.html" }
}
```| Setting | Description |
| --- | --- |
| AdminEmail | This is the email address used as the "from" address and also for any usage of the "SendToAdministrator" option |
| AdminName | This is the optional name for the sender for all outbound messages |
| Server | The SMTP Server address to use |
| Port | The Port to use for outbound emails |
| UseSsl | Should SSL be used for emails |
| SenderUsername | The username that should be used to connect to SMTP |
| SenderPassword | The password that should be used to connect to SMTP |
| AlwaysTemplateEmails | If selected ALL emails sent will be templated, by default using the "DefaultTemplate" as configured |
| AddEnvironmentSuffix | If selected, all outbound emails sent from non-production addresses will have the environment name added to the end of the subject |
| DefaultTemplatePath | The path, relative to the application root, where the default HTML template can be found for emails |
| AdditionalTemplates | These are name/value pairs of additional templates and totally optional |### Usage
Usage is primarly completed by injecting the `IEmailService` interface to your respective project, one injected emails can be sent with a single line of code.
``` csharp
_service.SendEmail("[email protected]", "My Subject", "Hello!
");
```Inline documentation exists for all API methods. We will continue to add more to this documentation in the future (PR's Welcome)
## Related Projects
ICG has a number of other related projects as well
* [NetCore.Utilities](https://www.github.com/iowacomputergurus/netcore.utilities)
* [AspNetCore.Utilities](https://www.github.com/iowacomputergurus/aspnetcore.utilities)
* [NetCore.Utilities.Email.SendGrid](https://www.github.com/iowacomputergurus/netcore.utilities.email.sendgrid)
* [NetCore.Utilities.Spreadsheet](https://www.github.com/iowacomputergurus/netcore.utilities.spreadsheet)
* [NetCore.Utilities.UnitTesting](https://www.github.com/iowacomputergurus/netcore.utilities.unittesting)