https://github.com/coronabytes/dotnet-email
.NET Transactional E-Mail Abstraction Layer
https://github.com/coronabytes/dotnet-email
awsses csharp dotnet email mailjet postmark sendgrid smtp transactional
Last synced: 7 months ago
JSON representation
.NET Transactional E-Mail Abstraction Layer
- Host: GitHub
- URL: https://github.com/coronabytes/dotnet-email
- Owner: coronabytes
- License: apache-2.0
- Created: 2024-01-18T00:59:43.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2024-02-08T19:15:15.000Z (over 1 year ago)
- Last Synced: 2024-05-15T18:11:36.961Z (over 1 year ago)
- Topics: awsses, csharp, dotnet, email, mailjet, postmark, sendgrid, smtp, transactional
- Language: C#
- Homepage:
- Size: 44.9 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
[](https://www.nuget.org/packages/Core.Email)
[](https://www.nuget.org/packages/Core.Email)```
dotnet add package Core.Email
dotnet add package Core.Email.Provider.SES
```# .NET Transactional E-Mail Abstraction Layer
- common providers
- smtp via mailkit
- aws ses
- mailjet
- sendgrid
- postmark
- TODO
- bounce handlers
# Usage
appsettings.json
```json
{
"Email": {
"Default": "Postmark",
"SMTP": {
"Host": "smtp.***.com",
"Port": 587,
"Username": "***",
"Password": "***",
"Tls": true
},
"SES": {
"AccessKey": "***",
"SecretAccessKey": "***",
"Region": "eu-central-1"
},
"Postmark": {
"ServerToken": "***",
"MessageStream": "outbound"
},
"Mailjet": {
"ApiKey": "***",
"ApiSecret": "***"
},
"SendGrid": {
"ApiKey": "***"
}
}
}
```- use .NET 8 keyed services to have multiple configurations of the same provider
- appsettings is matched with "Email:{key}"
```csharp
serviceCollection.AddCoreEmail();
serviceCollection.AddSmtpProvider("SMTP");
serviceCollection.AddPostmarkProvider("Postmark");
serviceCollection.AddSendGridProvider("SendGrid");
serviceCollection.AddMailjetProvider("Mailjet");
serviceCollection.AddSimpleEmailServiceProvider("SES");var email = serviceProvider.GetRequiredService();
await email.SendAsync(new CoreEmailMessage
{
To = ["test@example.com"],
From = "test@example.com",
Subject = "Transactional Mail Subject",
TextBody = "Transactional Mail Body",
Attachments = [new CoreEmailAttachment
{
Name = "File.txt",
ContentType = "text/plain",
Content = "Hello World!"u8.ToArray()
}]
});
```