Merged PR 88: .NET8 upgrade
parent
b84512ad09
commit
778543cbfd
|
@ -186,7 +186,7 @@
|
|||
same "printed page" as the copyright notice for easier
|
||||
identification within third-party archives.
|
||||
|
||||
Copyright [yyyy] [name of copyright owner]
|
||||
Copyright 2023 Tudor Stanciu
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
|
|
81
README.md
81
README.md
|
@ -1,25 +1,34 @@
|
|||
# Correo
|
||||
|
||||
Correo is a .NET service for programmatically sending emails. Communication with this service is available through two channels simultaneously:
|
||||
* HTTP (via REST API)
|
||||
* Pub/Sub Messaging (via NATS)
|
||||
**Correo** is a .NET service designed for programmatically sending emails. It supports communication through two simultaneous channels:
|
||||
|
||||
It can be integrated with several types of mediators, the configuration being the following:
|
||||
- **HTTP (via REST API)**
|
||||
- **Pub/Sub Messaging (via NATS)**
|
||||
|
||||
```"SmtpMediator": "SmtpClient", //SmtpClient, SendGrid, Mailgun```
|
||||
Correo can be integrated with various email mediators, offering flexible configuration options.
|
||||
|
||||
## Mediators
|
||||
## Mediator Configuration
|
||||
|
||||
### SMTP servers:
|
||||
* Local servers
|
||||
* Gmail
|
||||
* Yahoo
|
||||
|
||||
The integration with SMTP servers can be done through two libraries (.NET / MailKit), and the configuration area looks like this:
|
||||
Correo supports multiple email mediators, configured using the following setting:
|
||||
|
||||
```json
|
||||
"SmtpMediator": "SmtpClient" // Options: SmtpClient, SendGrid, Mailgun
|
||||
```
|
||||
|
||||
## Supported Mediators
|
||||
|
||||
### SMTP Servers
|
||||
Correo supports integration with standard SMTP email servers, including:
|
||||
|
||||
- **Local SMTP servers**
|
||||
- **Gmail**
|
||||
- **Yahoo**
|
||||
|
||||
SMTP integration is possible using either of two libraries: **.NET's built-in SMTP client** or **MailKit**. The configuration section in `appsettings.json` is as follows:
|
||||
|
||||
```json
|
||||
"SmtpClient": {
|
||||
"Package": "MailKit", //.NET, MailKit
|
||||
"Package": "MailKit", // Options: .NET, MailKit
|
||||
"Server": "smtp.gmail.com",
|
||||
"Port": "587",
|
||||
"UseAuthentication": true,
|
||||
|
@ -33,24 +42,29 @@ The integration with SMTP servers can be done through two libraries (.NET / Mail
|
|||
}
|
||||
```
|
||||
|
||||
### Transactional Email APIs:
|
||||
#### SendGrid
|
||||
### Transactional Email APIs
|
||||
|
||||
SendGrid is a cloud-based SMTP provider that allows you to send emails without having to maintain email servers. It has an excellent and easy-to-use email API with a free plan that allows you to send 100 emails per day.
|
||||
For this integration, the setup is very simple. All you need is an API Key generated from the [SendGrid](https://app.sendgrid.com/) platform. Afterwards, this API Key will be configured in Correo as below:
|
||||
Correo also supports transactional email APIs for scalable email sending solutions:
|
||||
|
||||
```
|
||||
"SmtpMediator": "SendGrid"
|
||||
#### **SendGrid**
|
||||
[SendGrid](https://app.sendgrid.com/) is a cloud-based SMTP provider that simplifies email sending without managing servers. It provides an easy-to-use API and a free plan allowing up to 100 emails per day.
|
||||
|
||||
To configure SendGrid, generate an API key from the SendGrid platform and update `appsettings.json`:
|
||||
|
||||
```json
|
||||
"SmtpMediator": "SendGrid",
|
||||
"SendGrid": {
|
||||
"ApiKey": "xxxxxxxxxxx"
|
||||
}
|
||||
```
|
||||
|
||||
#### Mailgun
|
||||
Mailgun is an email automation service that allows you to send, receive, and track emails. It offers a free usage plan as well as a pay-as-you-go pricing model that is based on the number of emails sent per month.
|
||||
For this integration, the setup is very simple. All you need is an API Key generated from the [Mailgun](https://app.mailgun.com/) platform and the domain name configured in Mailgun. Afterwards, this keys will be configured in Correo as below:
|
||||
```
|
||||
"SmtpMediator": "Mailgun"
|
||||
#### **Mailgun**
|
||||
[Mailgun](https://app.mailgun.com/) is an email automation service that offers transactional email APIs, with free and pay-as-you-go pricing options.
|
||||
|
||||
To configure Mailgun, generate an API key from Mailgun and specify the domain name in `appsettings.json`:
|
||||
|
||||
```json
|
||||
"SmtpMediator": "Mailgun",
|
||||
"Mailgun": {
|
||||
"ApiKey": "xxxxxxxxxxx",
|
||||
"Domain": "xxxxxxxxxxx"
|
||||
|
@ -58,10 +72,16 @@ For this integration, the setup is very simple. All you need is an API Key gener
|
|||
```
|
||||
|
||||
## Logging
|
||||
The logging functionality is managed with Serilog, and its configuration is done in the ```appsettings.json``` file. In addition to its standard configuration, Correo also has a preconfigured area where three destinations for logs are available: file, Postgres database and Seq. Each of the destinations can be activated or not. If logging in the console is sufficient, all additional logging destinations can be disabled.
|
||||
This configuration area is:
|
||||
|
||||
```
|
||||
Correo uses **Serilog** for logging, which can be configured in `appsettings.json`. It supports logging to multiple destinations:
|
||||
|
||||
- **File-based logging**
|
||||
- **PostgreSQL database logging**
|
||||
- **Seq (structured log management)**
|
||||
|
||||
The logging configuration section:
|
||||
|
||||
```json
|
||||
"Logs": {
|
||||
"File": {
|
||||
"Enabled": false,
|
||||
|
@ -80,4 +100,9 @@ This configuration area is:
|
|||
```
|
||||
|
||||
## Hosting
|
||||
The only hosting environment tested for this service is Docker, but considering that .NET 6 is cross platform, it can most likely be hosted in any environment.
|
||||
|
||||
Correo is primarily tested in **Docker** environments, but as it is built on **.NET 8**, it is cross-platform and can likely be hosted in various environments, including **Linux, Windows, and Kubernetes clusters**.
|
||||
|
||||
---
|
||||
|
||||
For further details and updates, visit the project repository or documentation.
|
||||
|
|
|
@ -1,16 +1,16 @@
|
|||
<Project>
|
||||
<PropertyGroup Label="Package Versions">
|
||||
<MicrosoftExtensionsPackageVersion>6.0.0</MicrosoftExtensionsPackageVersion>
|
||||
<SerilogPackageVersion>6.1.0</SerilogPackageVersion>
|
||||
<MicrosoftExtensionsPackageVersion>8.0.0</MicrosoftExtensionsPackageVersion>
|
||||
<SerilogPackageVersion>8.0.3</SerilogPackageVersion>
|
||||
<SerilogSinksPostgreSQLPackageVersion>2.3.0</SerilogSinksPostgreSQLPackageVersion>
|
||||
<SerilogSinksSeqPackageVersion>5.2.2</SerilogSinksSeqPackageVersion>
|
||||
<SwashbucklePackageVersion>6.2.3</SwashbucklePackageVersion>
|
||||
<AutoMapperPackageVersion>12.0.1</AutoMapperPackageVersion>
|
||||
<AutoMapperExtensionsPackageVersion>12.0.0</AutoMapperExtensionsPackageVersion>
|
||||
<MediatRPackageVersion>9.0.0</MediatRPackageVersion>
|
||||
<NBBPackageVersion>6.0.30</NBBPackageVersion>
|
||||
<MailKitPackageVersion>3.4.3</MailKitPackageVersion>
|
||||
<SendGridPackageVersion>9.28.1</SendGridPackageVersion>
|
||||
<RestSharpPackageVersion>108.0.3</RestSharpPackageVersion>
|
||||
<SerilogSinksSeqPackageVersion>8.0.0</SerilogSinksSeqPackageVersion>
|
||||
<SwashbucklePackageVersion>8.0.0</SwashbucklePackageVersion>
|
||||
<AutoMapperPackageVersion>14.0.0</AutoMapperPackageVersion>
|
||||
<MediatRPackageVersion>12.4.1</MediatRPackageVersion>
|
||||
<MediatRContractsPackageVersion>2.0.1</MediatRContractsPackageVersion>
|
||||
<NBBPackageVersion>8.0.4</NBBPackageVersion>
|
||||
<MailKitPackageVersion>4.11.0</MailKitPackageVersion>
|
||||
<SendGridPackageVersion>9.29.3</SendGridPackageVersion>
|
||||
<RestSharpPackageVersion>112.1.0</RestSharpPackageVersion>
|
||||
</PropertyGroup>
|
||||
</Project>
|
|
@ -1,7 +1,7 @@
|
|||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net6.0</TargetFramework>
|
||||
<TargetFramework>net8.0</TargetFramework>
|
||||
</PropertyGroup>
|
||||
|
||||
</Project>
|
||||
|
|
|
@ -1,4 +1,6 @@
|
|||
using System.Collections.Generic;
|
||||
// Copyright (c) 2023 Tudor Stanciu
|
||||
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Correo.Abstractions
|
||||
{
|
||||
|
|
|
@ -1,4 +1,6 @@
|
|||
using System.Collections.Generic;
|
||||
// Copyright (c) 2023 Tudor Stanciu
|
||||
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
|
||||
namespace Correo.Abstractions.Extensions
|
||||
|
|
|
@ -1,4 +1,6 @@
|
|||
using System.Threading;
|
||||
// Copyright (c) 2023 Tudor Stanciu
|
||||
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Correo.Abstractions
|
||||
|
|
|
@ -1,4 +1,6 @@
|
|||
using AutoMapper;
|
||||
// Copyright (c) 2023 Tudor Stanciu
|
||||
|
||||
using AutoMapper;
|
||||
using Correo.Abstractions;
|
||||
using Correo.Application.Extensions;
|
||||
using Correo.Domain.Models;
|
||||
|
@ -31,7 +33,7 @@ namespace Correo.Application.CommandHandlers
|
|||
_mailer=mailer;
|
||||
}
|
||||
|
||||
public async Task<Unit> Handle(SendEmail command, CancellationToken cancellationToken)
|
||||
public async Task Handle(SendEmail command, CancellationToken cancellationToken)
|
||||
{
|
||||
try
|
||||
{
|
||||
|
@ -47,8 +49,6 @@ namespace Correo.Application.CommandHandlers
|
|||
await _messageBusPublisher.PublishAsync(new EmailSentFailed(command.Subject, ex.Message), cancellationToken);
|
||||
throw;
|
||||
}
|
||||
|
||||
return Unit.Value;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,4 +1,6 @@
|
|||
using Correo.Abstractions;
|
||||
// Copyright (c) 2023 Tudor Stanciu
|
||||
|
||||
using Correo.Abstractions;
|
||||
using Correo.Application.Extensions;
|
||||
using Correo.Domain.Models;
|
||||
using MediatR;
|
||||
|
|
|
@ -1,11 +1,12 @@
|
|||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net6.0</TargetFramework>
|
||||
<TargetFramework>net8.0</TargetFramework>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="AutoMapper" Version="$(AutoMapperPackageVersion)" />
|
||||
<PackageReference Include="MediatR" Version="$(MediatRPackageVersion)" />
|
||||
<PackageReference Include="Microsoft.Extensions.Options.ConfigurationExtensions" Version="$(MicrosoftExtensionsPackageVersion)" />
|
||||
<PackageReference Include="NBB.Messaging.Abstractions" Version="$(NBBPackageVersion)" />
|
||||
</ItemGroup>
|
||||
|
|
|
@ -1,4 +1,6 @@
|
|||
using Correo.Domain.Models;
|
||||
// Copyright (c) 2023 Tudor Stanciu
|
||||
|
||||
using Correo.Domain.Models;
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
|
||||
|
|
|
@ -1,4 +1,6 @@
|
|||
using Correo.Abstractions;
|
||||
// Copyright (c) 2023 Tudor Stanciu
|
||||
|
||||
using Correo.Abstractions;
|
||||
using Correo.Domain.Models;
|
||||
|
||||
namespace Correo.Application.Extensions
|
||||
|
|
|
@ -1,4 +1,6 @@
|
|||
using Correo.Abstractions;
|
||||
// Copyright (c) 2023 Tudor Stanciu
|
||||
|
||||
using Correo.Abstractions;
|
||||
using Correo.Application.Utils;
|
||||
using System;
|
||||
using System.Linq;
|
||||
|
|
|
@ -1,4 +1,6 @@
|
|||
using AutoMapper;
|
||||
// Copyright (c) 2023 Tudor Stanciu
|
||||
|
||||
using AutoMapper;
|
||||
using Correo.Abstractions;
|
||||
using Correo.Application.CommandHandlers;
|
||||
using Correo.PublishedLanguage.Commands;
|
||||
|
|
|
@ -1,4 +1,6 @@
|
|||
using MediatR;
|
||||
// Copyright (c) 2023 Tudor Stanciu
|
||||
|
||||
using MediatR;
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Reflection;
|
||||
|
|
|
@ -1,4 +1,6 @@
|
|||
using System.Text.RegularExpressions;
|
||||
// Copyright (c) 2023 Tudor Stanciu
|
||||
|
||||
using System.Text.RegularExpressions;
|
||||
|
||||
namespace Correo.Application.Utils
|
||||
{
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net6.0</TargetFramework>
|
||||
<TargetFramework>net8.0</TargetFramework>
|
||||
</PropertyGroup>
|
||||
|
||||
</Project>
|
||||
|
|
|
@ -1,4 +1,6 @@
|
|||
namespace Correo.Domain.Models
|
||||
// Copyright (c) 2023 Tudor Stanciu
|
||||
|
||||
namespace Correo.Domain.Models
|
||||
{
|
||||
public record DefaultSender
|
||||
{
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net6.0</TargetFramework>
|
||||
<TargetFramework>net8.0</TargetFramework>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
|
|
@ -1,4 +1,6 @@
|
|||
using Correo.Abstractions;
|
||||
// Copyright (c) 2023 Tudor Stanciu
|
||||
|
||||
using Correo.Abstractions;
|
||||
using Correo.MailKit.Models;
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
|
@ -13,4 +15,4 @@ namespace Correo.MailKit
|
|||
services.AddTransient<IMailer, MailKitSmtpClient>();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,4 +1,6 @@
|
|||
using Correo.Abstractions;
|
||||
// Copyright (c) 2023 Tudor Stanciu
|
||||
|
||||
using Correo.Abstractions;
|
||||
using MimeKit;
|
||||
using System.Collections.Generic;
|
||||
|
||||
|
|
|
@ -1,4 +1,6 @@
|
|||
using Correo.Abstractions;
|
||||
// Copyright (c) 2023 Tudor Stanciu
|
||||
|
||||
using Correo.Abstractions;
|
||||
using Correo.Abstractions.Extensions;
|
||||
using Correo.MailKit.Extensions;
|
||||
using Correo.MailKit.Models;
|
||||
|
|
|
@ -1,4 +1,6 @@
|
|||
namespace Correo.MailKit.Models
|
||||
// Copyright (c) 2023 Tudor Stanciu
|
||||
|
||||
namespace Correo.MailKit.Models
|
||||
{
|
||||
public record SmtpClientOptions
|
||||
{
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net6.0</TargetFramework>
|
||||
<TargetFramework>net8.0</TargetFramework>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
|
|
@ -1,4 +1,6 @@
|
|||
using Correo.Abstractions;
|
||||
// Copyright (c) 2023 Tudor Stanciu
|
||||
|
||||
using Correo.Abstractions;
|
||||
using Correo.Mailgun.Models;
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
|
@ -13,4 +15,4 @@ namespace Correo.Mailgun
|
|||
services.AddTransient<IMailer, MailgunService>();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,4 +1,6 @@
|
|||
using Correo.Abstractions;
|
||||
// Copyright (c) 2023 Tudor Stanciu
|
||||
|
||||
using Correo.Abstractions;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
|
||||
|
|
|
@ -1,4 +1,6 @@
|
|||
using Correo.Abstractions;
|
||||
// Copyright (c) 2023 Tudor Stanciu
|
||||
|
||||
using Correo.Abstractions;
|
||||
using Correo.Abstractions.Extensions;
|
||||
using Correo.Mailgun.Extensions;
|
||||
using Correo.Mailgun.Models;
|
||||
|
@ -22,10 +24,7 @@ namespace Correo.Mailgun
|
|||
{
|
||||
_optionsAccessor = optionsAccessor;
|
||||
_logger = logger;
|
||||
_client = new RestClient("https://api.mailgun.net/v3")
|
||||
{
|
||||
Authenticator = new HttpBasicAuthenticator("api", _optionsAccessor.Value.ApiKey)
|
||||
};
|
||||
_client = new RestClient("https://api.mailgun.net/v3");
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
|
@ -61,6 +60,7 @@ namespace Correo.Mailgun
|
|||
request.AddParameter("bcc", bcc);
|
||||
|
||||
request.Method = Method.Post;
|
||||
request.Authenticator = new HttpBasicAuthenticator("api", _optionsAccessor.Value.ApiKey);
|
||||
var response = await _client.ExecuteAsync<MailgunResponse>(request, token);
|
||||
if (response.IsSuccessful)
|
||||
{
|
||||
|
|
|
@ -1,4 +1,6 @@
|
|||
namespace Correo.Mailgun.Models
|
||||
// Copyright (c) 2023 Tudor Stanciu
|
||||
|
||||
namespace Correo.Mailgun.Models
|
||||
{
|
||||
internal record MailgunOptions
|
||||
{
|
||||
|
|
|
@ -1,4 +1,6 @@
|
|||
namespace Correo.Mailgun.Models
|
||||
// Copyright (c) 2023 Tudor Stanciu
|
||||
|
||||
namespace Correo.Mailgun.Models
|
||||
{
|
||||
public record MailgunResponse
|
||||
{
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net6.0</TargetFramework>
|
||||
<TargetFramework>net8.0</TargetFramework>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
|
|
@ -1,4 +1,6 @@
|
|||
using Correo.Abstractions;
|
||||
// Copyright (c) 2023 Tudor Stanciu
|
||||
|
||||
using Correo.Abstractions;
|
||||
using Correo.NetSmtpClient.Models;
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
|
@ -13,4 +15,4 @@ namespace Correo.NetSmtpClient
|
|||
services.AddTransient<IMailer, NetSmtpClient>();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,4 +1,6 @@
|
|||
using Correo.Abstractions;
|
||||
// Copyright (c) 2023 Tudor Stanciu
|
||||
|
||||
using Correo.Abstractions;
|
||||
using System.Collections.Generic;
|
||||
using System.Net.Mail;
|
||||
|
||||
|
|
|
@ -1,4 +1,6 @@
|
|||
namespace Correo.NetSmtpClient.Models
|
||||
// Copyright (c) 2023 Tudor Stanciu
|
||||
|
||||
namespace Correo.NetSmtpClient.Models
|
||||
{
|
||||
public record SmtpClientOptions
|
||||
{
|
||||
|
|
|
@ -1,4 +1,6 @@
|
|||
using Correo.Abstractions;
|
||||
// Copyright (c) 2023 Tudor Stanciu
|
||||
|
||||
using Correo.Abstractions;
|
||||
using Correo.Abstractions.Extensions;
|
||||
using Correo.NetSmtpClient.Extensions;
|
||||
using Correo.NetSmtpClient.Models;
|
||||
|
|
|
@ -1,4 +1,6 @@
|
|||
using MediatR;
|
||||
// Copyright (c) 2023 Tudor Stanciu
|
||||
|
||||
using MediatR;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Correo.PublishedLanguage.Commands
|
||||
|
|
|
@ -1,17 +1,34 @@
|
|||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net6.0</TargetFramework>
|
||||
<Version>1.0.1</Version>
|
||||
<TargetFramework>net8.0</TargetFramework>
|
||||
<Version>1.1.0</Version>
|
||||
<Description>Correo.PublishedLanguage is a NuGet package that encapsulates the published language of Correo. It streamlines communication with the server in a .NET environment by providing essential DTOs (Data Transfer Objects) and constants.</Description>
|
||||
<PackageProjectUrl>https://lab.code-rove.com/gitea/tudor.stanciu/correo</PackageProjectUrl>
|
||||
<RepositoryUrl>https://lab.code-rove.com/gitea/tudor.stanciu/correo</RepositoryUrl>
|
||||
<RepositoryType>Git</RepositoryType>
|
||||
<PackageReleaseNotes>$([System.IO.File]::ReadAllText("$(MSBuildProjectDirectory)/ReleaseNotes.txt"))</PackageReleaseNotes>
|
||||
<PackageIcon>correo.png</PackageIcon>
|
||||
<Description>Correo published language</Description>
|
||||
<PackageReadmeFile>README.md</PackageReadmeFile>
|
||||
<Company>Toodle HomeLab</Company>
|
||||
<Copyright>Toodle Correo</Copyright>
|
||||
<PackageTags>Correo HomeLab CodeRove</PackageTags>
|
||||
<PackageLicenseExpression>Apache-2.0</PackageLicenseExpression>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="MediatR" Version="$(MediatRPackageVersion)" />
|
||||
<PackageReference Include="MediatR.Contracts" Version="$(MediatRContractsPackageVersion)" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Content Include="..\..\LICENSE.txt" Link="LICENSE.txt">
|
||||
<Pack>true</Pack>
|
||||
<PackagePath>/</PackagePath>
|
||||
</Content>
|
||||
<None Update="README.md">
|
||||
<Pack>True</Pack>
|
||||
<PackagePath>\</PackagePath>
|
||||
</None>
|
||||
<None Update="correo.png">
|
||||
<Pack>True</Pack>
|
||||
<PackagePath>\</PackagePath>
|
||||
|
|
|
@ -1,4 +1,6 @@
|
|||
using MediatR;
|
||||
// Copyright (c) 2023 Tudor Stanciu
|
||||
|
||||
using MediatR;
|
||||
|
||||
namespace Correo.PublishedLanguage.Events
|
||||
{
|
||||
|
|
|
@ -0,0 +1,73 @@
|
|||
# Correo.PublishedLanguage
|
||||
|
||||
[Correo](https://lab.code-rove.com/gitea/tudor.stanciu/correo) is a .NET service for programmatically sending emails. Communication with this service is available through two channels:
|
||||
|
||||
- **HTTP** (via REST API)
|
||||
- **Pub/Sub Messaging** (via NATS)
|
||||
|
||||
**Correo.PublishedLanguage** is a NuGet package that encapsulates the published language of **Correo**. It streamlines communication with the server in a .NET environment by providing essential **DTOs (Data Transfer Objects)** and constants. This package equips developers with the necessary tools to integrate the API's functionality into their applications using clear and consistent data structures.
|
||||
|
||||
## Key Features
|
||||
|
||||
- Provides pre-defined DTOs for seamless communication with Correo.
|
||||
- Includes constants for maintaining consistency across applications.
|
||||
- Supports both HTTP and Pub/Sub messaging channels.
|
||||
- Simplifies integration with Correo's email service.
|
||||
|
||||
By leveraging **Correo.PublishedLanguage**, developers can effortlessly incorporate email-sending functionalities into their applications, improving user notifications and communication workflows.
|
||||
|
||||
## Package Repository
|
||||
|
||||
You can install **Correo.PublishedLanguage** from my self-hosted NuGet feed: [https://lab.code-rove.com/public-nuget-server/](https://lab.code-rove.com/public-nuget-server/)
|
||||
|
||||
## Installation
|
||||
|
||||
### Visual Studio
|
||||
|
||||
#### NuGet.config File
|
||||
|
||||
To integrate the package, configure your Visual Studio solution with the following `NuGet.config` file:
|
||||
|
||||
```xml
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<configuration>
|
||||
<packageSources>
|
||||
<clear />
|
||||
<add key="nuget.org" value="https://api.nuget.org/v3/index.json" />
|
||||
<add key="lab.nuget" value="https://lab.code-rove.com/public-nuget-server/v3/index.json" />
|
||||
</packageSources>
|
||||
</configuration>
|
||||
```
|
||||
|
||||
Add this `NuGet.config` file to your solution directory, or alternatively, configure the new NuGet feed in the NuGet Package Manager within Visual Studio. After completing this setup, you can install `Correo.PublishedLanguage` using the NuGet Package Manager.
|
||||
|
||||
### CLI
|
||||
|
||||
To install the package via the command line, run the following command in a terminal within your .NET project directory:
|
||||
|
||||
```bash
|
||||
dotnet add package Correo.PublishedLanguage --source https://lab.code-rove.com/public-nuget-server/v3/index.json
|
||||
```
|
||||
|
||||
## Usage
|
||||
|
||||
Once installed, you can use the DTOs and constants provided by the package to communicate effectively with Correo’s API. Here's an example of how to use a DTO in your application:
|
||||
|
||||
```csharp
|
||||
using NetworkResurrector.Server.PublishedLanguage;
|
||||
|
||||
// Example usage of a DTO from the package
|
||||
var cmd = new SendEmail()
|
||||
{
|
||||
Subject = "Hello from Correo",
|
||||
Body = "Hello from Correo",
|
||||
IsBodyHtml = false,
|
||||
To = [ "user@homelab.com" ]
|
||||
};
|
||||
|
||||
await _messageBusPublisher.PublishAsync(cmd);
|
||||
|
||||
// Your logic here
|
||||
```
|
||||
|
||||
This package simplifies email integration within your .NET applications, ensuring efficient and reliable messaging capabilities.
|
|
@ -0,0 +1,9 @@
|
|||
1.1.0 release [2025-03-29 14:34]
|
||||
◾ Added support for .NET 8.0
|
||||
◾ Added release notes and readme files
|
||||
|
||||
1.0.1 release [2023-01-29 00:33]
|
||||
◾ Small fix for Mailgun email address
|
||||
|
||||
1.0.0 release [2023-01-18 2:12]
|
||||
◾ Initial release of Correo.PublishedLanguage
|
|
@ -1,7 +1,7 @@
|
|||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net6.0</TargetFramework>
|
||||
<TargetFramework>net8.0</TargetFramework>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
|
|
@ -1,4 +1,6 @@
|
|||
using Correo.Abstractions;
|
||||
// Copyright (c) 2023 Tudor Stanciu
|
||||
|
||||
using Correo.Abstractions;
|
||||
using Correo.SendGrid.Models;
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
|
@ -13,4 +15,4 @@ namespace Correo.SendGrid
|
|||
services.AddTransient<IMailer, SendGridService>();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,4 +1,6 @@
|
|||
using Correo.Abstractions;
|
||||
// Copyright (c) 2023 Tudor Stanciu
|
||||
|
||||
using Correo.Abstractions;
|
||||
using SendGrid.Helpers.Mail;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
|
|
|
@ -1,4 +1,6 @@
|
|||
namespace Correo.SendGrid.Models
|
||||
// Copyright (c) 2023 Tudor Stanciu
|
||||
|
||||
namespace Correo.SendGrid.Models
|
||||
{
|
||||
internal record Error
|
||||
{
|
||||
|
|
|
@ -1,4 +1,6 @@
|
|||
namespace Correo.SendGrid.Models
|
||||
// Copyright (c) 2023 Tudor Stanciu
|
||||
|
||||
namespace Correo.SendGrid.Models
|
||||
{
|
||||
internal record SendGridOptions
|
||||
{
|
||||
|
|
|
@ -1,4 +1,6 @@
|
|||
using Correo.Abstractions;
|
||||
// Copyright (c) 2023 Tudor Stanciu
|
||||
|
||||
using Correo.Abstractions;
|
||||
using Correo.Abstractions.Extensions;
|
||||
using Correo.SendGrid.Extensions;
|
||||
using Correo.SendGrid.Models;
|
||||
|
|
|
@ -1,4 +1,6 @@
|
|||
using AutoMapper;
|
||||
// Copyright (c) 2023 Tudor Stanciu
|
||||
|
||||
using AutoMapper;
|
||||
using Correo.Application.CommandHandlers;
|
||||
using Correo.PublishedLanguage.Commands;
|
||||
using MediatR;
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
// Copyright (c) 2023 Tudor Stanciu
|
||||
|
||||
using Correo.Application.Queries;
|
||||
using MediatR;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
|
@ -30,4 +32,4 @@ namespace Correo.Controllers
|
|||
return Ok(result);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,14 +1,12 @@
|
|||
<Project Sdk="Microsoft.NET.Sdk.Web">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net6.0</TargetFramework>
|
||||
<TargetFramework>net8.0</TargetFramework>
|
||||
<DockerDefaultTargetOS>Linux</DockerDefaultTargetOS>
|
||||
<DockerfileContext>..\..</DockerfileContext>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="AutoMapper.Extensions.Microsoft.DependencyInjection" Version="$(AutoMapperExtensionsPackageVersion)" />
|
||||
<PackageReference Include="MediatR.Extensions.Microsoft.DependencyInjection" Version="$(MediatRPackageVersion)" />
|
||||
<PackageReference Include="NBB.Messaging.Host" Version="$(NBBPackageVersion)" />
|
||||
<PackageReference Include="NBB.Messaging.Nats" Version="$(NBBPackageVersion)" />
|
||||
<PackageReference Include="Serilog.AspNetCore" Version="$(SerilogPackageVersion)" />
|
||||
|
|
|
@ -1,10 +1,11 @@
|
|||
#See https://aka.ms/containerfastmode to understand how Visual Studio uses this Dockerfile to build your images for faster debugging.
|
||||
|
||||
FROM mcr.microsoft.com/dotnet/aspnet:6.0-bullseye-slim AS base
|
||||
FROM --platform=$BUILDPLATFORM mcr.microsoft.com/dotnet/aspnet:8.0 AS base
|
||||
WORKDIR /app
|
||||
EXPOSE 80
|
||||
|
||||
FROM mcr.microsoft.com/dotnet/sdk:6.0-bullseye-slim AS build
|
||||
FROM --platform=$BUILDPLATFORM mcr.microsoft.com/dotnet/sdk:8.0 AS build
|
||||
ARG BUILD_CONFIGURATION=Release
|
||||
WORKDIR /workspace
|
||||
COPY ["dependencies.props", "."]
|
||||
COPY ["Directory.Build.props", "."]
|
||||
|
@ -21,10 +22,11 @@ COPY ["src/Correo.SendGrid/Correo.SendGrid.csproj", "src/Correo.SendGrid/"]
|
|||
RUN dotnet restore "src/Correo/Correo.csproj"
|
||||
COPY . .
|
||||
WORKDIR "/workspace/src/Correo"
|
||||
RUN dotnet build "Correo.csproj" -c Release -o /app/build
|
||||
RUN dotnet build "Correo.csproj" -c $BUILD_CONFIGURATION -o /app/build
|
||||
|
||||
FROM build AS publish
|
||||
RUN dotnet publish "Correo.csproj" -c Release -o /app/publish /p:UseAppHost=false
|
||||
ARG BUILD_CONFIGURATION=Release
|
||||
RUN dotnet publish "Correo.csproj" -c $BUILD_CONFIGURATION -o /app/publish /p:UseAppHost=false
|
||||
|
||||
FROM base AS final
|
||||
WORKDIR /app
|
||||
|
|
|
@ -1,4 +1,6 @@
|
|||
using System;
|
||||
// Copyright (c) 2023 Tudor Stanciu
|
||||
|
||||
using System;
|
||||
|
||||
namespace Correo.Extensions
|
||||
{
|
||||
|
|
|
@ -1,4 +1,6 @@
|
|||
using Microsoft.Extensions.Configuration;
|
||||
// Copyright (c) 2023 Tudor Stanciu
|
||||
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using NpgsqlTypes;
|
||||
using Serilog;
|
||||
using Serilog.Sinks.PostgreSQL;
|
||||
|
|
|
@ -1,4 +1,6 @@
|
|||
using Correo.Middlewares;
|
||||
// Copyright (c) 2023 Tudor Stanciu
|
||||
|
||||
using Correo.Middlewares;
|
||||
using MediatR;
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
|
|
|
@ -1,4 +1,6 @@
|
|||
using Correo.Mailgun;
|
||||
// Copyright (c) 2023 Tudor Stanciu
|
||||
|
||||
using Correo.Mailgun;
|
||||
using Correo.MailKit;
|
||||
using Correo.NetSmtpClient;
|
||||
using Correo.SendGrid;
|
||||
|
|
|
@ -1,4 +1,6 @@
|
|||
using Correo.Application;
|
||||
// Copyright (c) 2023 Tudor Stanciu
|
||||
|
||||
using Correo.Application;
|
||||
using MediatR;
|
||||
using MediatR.Pipeline;
|
||||
using Microsoft.AspNetCore.Builder;
|
||||
|
@ -23,7 +25,7 @@ namespace Correo.Extensions
|
|||
services.AddAutoMapper(typeof(Application.Mappings.MappingProfile).Assembly);
|
||||
|
||||
// MediatR
|
||||
services.AddMediatR(typeof(Application.Queries.GetSystemVersion).Assembly);
|
||||
services.AddMediatR(cfg => cfg.RegisterServicesFromAssemblyContaining<Application.Queries.GetSystemVersion>());
|
||||
services.AddScoped(typeof(IPipelineBehavior<,>), typeof(RequestPreProcessorBehavior<,>));
|
||||
|
||||
// Messaging
|
||||
|
|
|
@ -1,4 +1,6 @@
|
|||
using Microsoft.Extensions.Logging;
|
||||
// Copyright (c) 2023 Tudor Stanciu
|
||||
|
||||
using Microsoft.Extensions.Logging;
|
||||
using System.Threading.Tasks;
|
||||
using System.Threading;
|
||||
using System;
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
// Copyright (c) 2023 Tudor Stanciu
|
||||
|
||||
using Correo.Extensions;
|
||||
using Microsoft.AspNetCore.Builder;
|
||||
using Microsoft.Extensions.Configuration;
|
||||
|
@ -46,4 +48,4 @@ namespace Correo
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue