diff --git a/LICENSE.txt b/LICENSE.txt index 261eeb9..0514cef 100644 --- a/LICENSE.txt +++ b/LICENSE.txt @@ -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. diff --git a/README.md b/README.md index ede41fa..87a2294 100644 --- a/README.md +++ b/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. \ No newline at end of file + +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. diff --git a/dependencies.props b/dependencies.props index 7b5f51f..9827be2 100644 --- a/dependencies.props +++ b/dependencies.props @@ -1,16 +1,16 @@ - 6.0.0 - 6.1.0 + 8.0.0 + 8.0.3 2.3.0 - 5.2.2 - 6.2.3 - 12.0.1 - 12.0.0 - 9.0.0 - 6.0.30 - 3.4.3 - 9.28.1 - 108.0.3 + 8.0.0 + 8.0.0 + 14.0.0 + 12.4.1 + 2.0.1 + 8.0.4 + 4.11.0 + 9.29.3 + 112.1.0 \ No newline at end of file diff --git a/src/Correo.Abstractions/Correo.Abstractions.csproj b/src/Correo.Abstractions/Correo.Abstractions.csproj index dbc1517..58990cd 100644 --- a/src/Correo.Abstractions/Correo.Abstractions.csproj +++ b/src/Correo.Abstractions/Correo.Abstractions.csproj @@ -1,7 +1,7 @@ - net6.0 + net8.0 diff --git a/src/Correo.Abstractions/EmailMessage.cs b/src/Correo.Abstractions/EmailMessage.cs index e70d49a..5c17008 100644 --- a/src/Correo.Abstractions/EmailMessage.cs +++ b/src/Correo.Abstractions/EmailMessage.cs @@ -1,4 +1,6 @@ -using System.Collections.Generic; +// Copyright (c) 2023 Tudor Stanciu + +using System.Collections.Generic; namespace Correo.Abstractions { diff --git a/src/Correo.Abstractions/Extensions/ModelExtensions.cs b/src/Correo.Abstractions/Extensions/ModelExtensions.cs index ca52c7c..b7a0a6e 100644 --- a/src/Correo.Abstractions/Extensions/ModelExtensions.cs +++ b/src/Correo.Abstractions/Extensions/ModelExtensions.cs @@ -1,4 +1,6 @@ -using System.Collections.Generic; +// Copyright (c) 2023 Tudor Stanciu + +using System.Collections.Generic; using System.Linq; namespace Correo.Abstractions.Extensions diff --git a/src/Correo.Abstractions/IMailer.cs b/src/Correo.Abstractions/IMailer.cs index 194f854..95037f1 100644 --- a/src/Correo.Abstractions/IMailer.cs +++ b/src/Correo.Abstractions/IMailer.cs @@ -1,4 +1,6 @@ -using System.Threading; +// Copyright (c) 2023 Tudor Stanciu + +using System.Threading; using System.Threading.Tasks; namespace Correo.Abstractions diff --git a/src/Correo.Application/CommandHandlers/SendEmailHandler.cs b/src/Correo.Application/CommandHandlers/SendEmailHandler.cs index 862f4ea..6b3f5bf 100644 --- a/src/Correo.Application/CommandHandlers/SendEmailHandler.cs +++ b/src/Correo.Application/CommandHandlers/SendEmailHandler.cs @@ -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 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; } } } diff --git a/src/Correo.Application/CommandHandlers/SendEmailHandlerSync.cs b/src/Correo.Application/CommandHandlers/SendEmailHandlerSync.cs index 6d7441b..61b5ea0 100644 --- a/src/Correo.Application/CommandHandlers/SendEmailHandlerSync.cs +++ b/src/Correo.Application/CommandHandlers/SendEmailHandlerSync.cs @@ -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; diff --git a/src/Correo.Application/Correo.Application.csproj b/src/Correo.Application/Correo.Application.csproj index abbbfb9..373690d 100644 --- a/src/Correo.Application/Correo.Application.csproj +++ b/src/Correo.Application/Correo.Application.csproj @@ -1,11 +1,12 @@  - net6.0 + net8.0 + diff --git a/src/Correo.Application/DependencyInjectionExtensions.cs b/src/Correo.Application/DependencyInjectionExtensions.cs index 0fd3631..9e6aec8 100644 --- a/src/Correo.Application/DependencyInjectionExtensions.cs +++ b/src/Correo.Application/DependencyInjectionExtensions.cs @@ -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; diff --git a/src/Correo.Application/Extensions/ModelExtensions.cs b/src/Correo.Application/Extensions/ModelExtensions.cs index 023bd2d..c3abef5 100644 --- a/src/Correo.Application/Extensions/ModelExtensions.cs +++ b/src/Correo.Application/Extensions/ModelExtensions.cs @@ -1,4 +1,6 @@ -using Correo.Abstractions; +// Copyright (c) 2023 Tudor Stanciu + +using Correo.Abstractions; using Correo.Domain.Models; namespace Correo.Application.Extensions diff --git a/src/Correo.Application/Extensions/ValidationExtensions.cs b/src/Correo.Application/Extensions/ValidationExtensions.cs index fc921f7..113c051 100644 --- a/src/Correo.Application/Extensions/ValidationExtensions.cs +++ b/src/Correo.Application/Extensions/ValidationExtensions.cs @@ -1,4 +1,6 @@ -using Correo.Abstractions; +// Copyright (c) 2023 Tudor Stanciu + +using Correo.Abstractions; using Correo.Application.Utils; using System; using System.Linq; diff --git a/src/Correo.Application/Mappings/MappingProfile.cs b/src/Correo.Application/Mappings/MappingProfile.cs index 728f11c..2af7745 100644 --- a/src/Correo.Application/Mappings/MappingProfile.cs +++ b/src/Correo.Application/Mappings/MappingProfile.cs @@ -1,4 +1,6 @@ -using AutoMapper; +// Copyright (c) 2023 Tudor Stanciu + +using AutoMapper; using Correo.Abstractions; using Correo.Application.CommandHandlers; using Correo.PublishedLanguage.Commands; diff --git a/src/Correo.Application/Queries/GetSystemVersion.cs b/src/Correo.Application/Queries/GetSystemVersion.cs index d26a8b0..edf9e4a 100644 --- a/src/Correo.Application/Queries/GetSystemVersion.cs +++ b/src/Correo.Application/Queries/GetSystemVersion.cs @@ -1,4 +1,6 @@ -using MediatR; +// Copyright (c) 2023 Tudor Stanciu + +using MediatR; using System; using System.IO; using System.Reflection; diff --git a/src/Correo.Application/Utils/Validations.cs b/src/Correo.Application/Utils/Validations.cs index 2d87883..3a3632d 100644 --- a/src/Correo.Application/Utils/Validations.cs +++ b/src/Correo.Application/Utils/Validations.cs @@ -1,4 +1,6 @@ -using System.Text.RegularExpressions; +// Copyright (c) 2023 Tudor Stanciu + +using System.Text.RegularExpressions; namespace Correo.Application.Utils { diff --git a/src/Correo.Domain/Correo.Domain.csproj b/src/Correo.Domain/Correo.Domain.csproj index dbc1517..58990cd 100644 --- a/src/Correo.Domain/Correo.Domain.csproj +++ b/src/Correo.Domain/Correo.Domain.csproj @@ -1,7 +1,7 @@ - net6.0 + net8.0 diff --git a/src/Correo.Domain/Models/Settings.cs b/src/Correo.Domain/Models/Settings.cs index b3af19d..51a2901 100644 --- a/src/Correo.Domain/Models/Settings.cs +++ b/src/Correo.Domain/Models/Settings.cs @@ -1,4 +1,6 @@ -namespace Correo.Domain.Models +// Copyright (c) 2023 Tudor Stanciu + +namespace Correo.Domain.Models { public record DefaultSender { diff --git a/src/Correo.MailKit/Correo.MailKit.csproj b/src/Correo.MailKit/Correo.MailKit.csproj index 3ae22fb..235d99d 100644 --- a/src/Correo.MailKit/Correo.MailKit.csproj +++ b/src/Correo.MailKit/Correo.MailKit.csproj @@ -1,7 +1,7 @@  - net6.0 + net8.0 diff --git a/src/Correo.MailKit/DependencyInjectionExtensions.cs b/src/Correo.MailKit/DependencyInjectionExtensions.cs index 05bb39b..31299bd 100644 --- a/src/Correo.MailKit/DependencyInjectionExtensions.cs +++ b/src/Correo.MailKit/DependencyInjectionExtensions.cs @@ -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(); } } -} \ No newline at end of file +} diff --git a/src/Correo.MailKit/Extensions/ModelExtensions.cs b/src/Correo.MailKit/Extensions/ModelExtensions.cs index 054d617..688ecfe 100644 --- a/src/Correo.MailKit/Extensions/ModelExtensions.cs +++ b/src/Correo.MailKit/Extensions/ModelExtensions.cs @@ -1,4 +1,6 @@ -using Correo.Abstractions; +// Copyright (c) 2023 Tudor Stanciu + +using Correo.Abstractions; using MimeKit; using System.Collections.Generic; diff --git a/src/Correo.MailKit/MailKitSmtpClient.cs b/src/Correo.MailKit/MailKitSmtpClient.cs index c5cd92d..37656ef 100644 --- a/src/Correo.MailKit/MailKitSmtpClient.cs +++ b/src/Correo.MailKit/MailKitSmtpClient.cs @@ -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; diff --git a/src/Correo.MailKit/Models/SmtpClientOptions.cs b/src/Correo.MailKit/Models/SmtpClientOptions.cs index 6bb80d9..b05695b 100644 --- a/src/Correo.MailKit/Models/SmtpClientOptions.cs +++ b/src/Correo.MailKit/Models/SmtpClientOptions.cs @@ -1,4 +1,6 @@ -namespace Correo.MailKit.Models +// Copyright (c) 2023 Tudor Stanciu + +namespace Correo.MailKit.Models { public record SmtpClientOptions { diff --git a/src/Correo.Mailgun/Correo.Mailgun.csproj b/src/Correo.Mailgun/Correo.Mailgun.csproj index b496ce3..d8ce62b 100644 --- a/src/Correo.Mailgun/Correo.Mailgun.csproj +++ b/src/Correo.Mailgun/Correo.Mailgun.csproj @@ -1,7 +1,7 @@  - net6.0 + net8.0 diff --git a/src/Correo.Mailgun/DependencyInjectionExtensions.cs b/src/Correo.Mailgun/DependencyInjectionExtensions.cs index 81d34a5..1bde2d0 100644 --- a/src/Correo.Mailgun/DependencyInjectionExtensions.cs +++ b/src/Correo.Mailgun/DependencyInjectionExtensions.cs @@ -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(); } } -} \ No newline at end of file +} diff --git a/src/Correo.Mailgun/Extensions/ModelExtensions.cs b/src/Correo.Mailgun/Extensions/ModelExtensions.cs index 81ff4c1..1dd8aa0 100644 --- a/src/Correo.Mailgun/Extensions/ModelExtensions.cs +++ b/src/Correo.Mailgun/Extensions/ModelExtensions.cs @@ -1,4 +1,6 @@ -using Correo.Abstractions; +// Copyright (c) 2023 Tudor Stanciu + +using Correo.Abstractions; using System.Collections.Generic; using System.Linq; diff --git a/src/Correo.Mailgun/MailgunService.cs b/src/Correo.Mailgun/MailgunService.cs index 55d7576..3f3881e 100644 --- a/src/Correo.Mailgun/MailgunService.cs +++ b/src/Correo.Mailgun/MailgunService.cs @@ -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(request, token); if (response.IsSuccessful) { diff --git a/src/Correo.Mailgun/Models/MailgunOptions.cs b/src/Correo.Mailgun/Models/MailgunOptions.cs index 0ba1ccf..79c1191 100644 --- a/src/Correo.Mailgun/Models/MailgunOptions.cs +++ b/src/Correo.Mailgun/Models/MailgunOptions.cs @@ -1,4 +1,6 @@ -namespace Correo.Mailgun.Models +// Copyright (c) 2023 Tudor Stanciu + +namespace Correo.Mailgun.Models { internal record MailgunOptions { diff --git a/src/Correo.Mailgun/Models/MailgunResponse.cs b/src/Correo.Mailgun/Models/MailgunResponse.cs index 6a4dbba..86d58f8 100644 --- a/src/Correo.Mailgun/Models/MailgunResponse.cs +++ b/src/Correo.Mailgun/Models/MailgunResponse.cs @@ -1,4 +1,6 @@ -namespace Correo.Mailgun.Models +// Copyright (c) 2023 Tudor Stanciu + +namespace Correo.Mailgun.Models { public record MailgunResponse { diff --git a/src/Correo.NetSmtpClient/Correo.NetSmtpClient.csproj b/src/Correo.NetSmtpClient/Correo.NetSmtpClient.csproj index cc62f91..8cfec68 100644 --- a/src/Correo.NetSmtpClient/Correo.NetSmtpClient.csproj +++ b/src/Correo.NetSmtpClient/Correo.NetSmtpClient.csproj @@ -1,7 +1,7 @@  - net6.0 + net8.0 diff --git a/src/Correo.NetSmtpClient/DependencyInjectionExtensions.cs b/src/Correo.NetSmtpClient/DependencyInjectionExtensions.cs index 40f51f1..6599001 100644 --- a/src/Correo.NetSmtpClient/DependencyInjectionExtensions.cs +++ b/src/Correo.NetSmtpClient/DependencyInjectionExtensions.cs @@ -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(); } } -} \ No newline at end of file +} diff --git a/src/Correo.NetSmtpClient/Extensions/ModelExtensions.cs b/src/Correo.NetSmtpClient/Extensions/ModelExtensions.cs index 2b40cb0..4ed98b3 100644 --- a/src/Correo.NetSmtpClient/Extensions/ModelExtensions.cs +++ b/src/Correo.NetSmtpClient/Extensions/ModelExtensions.cs @@ -1,4 +1,6 @@ -using Correo.Abstractions; +// Copyright (c) 2023 Tudor Stanciu + +using Correo.Abstractions; using System.Collections.Generic; using System.Net.Mail; diff --git a/src/Correo.NetSmtpClient/Models/SmtpClientOptions.cs b/src/Correo.NetSmtpClient/Models/SmtpClientOptions.cs index 9b1928d..9f43018 100644 --- a/src/Correo.NetSmtpClient/Models/SmtpClientOptions.cs +++ b/src/Correo.NetSmtpClient/Models/SmtpClientOptions.cs @@ -1,4 +1,6 @@ -namespace Correo.NetSmtpClient.Models +// Copyright (c) 2023 Tudor Stanciu + +namespace Correo.NetSmtpClient.Models { public record SmtpClientOptions { diff --git a/src/Correo.NetSmtpClient/NetSmtpClient.cs b/src/Correo.NetSmtpClient/NetSmtpClient.cs index 9275290..7de2c76 100644 --- a/src/Correo.NetSmtpClient/NetSmtpClient.cs +++ b/src/Correo.NetSmtpClient/NetSmtpClient.cs @@ -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; diff --git a/src/Correo.PublishedLanguage/Commands/SendEmail.cs b/src/Correo.PublishedLanguage/Commands/SendEmail.cs index 91ffe27..4abf277 100644 --- a/src/Correo.PublishedLanguage/Commands/SendEmail.cs +++ b/src/Correo.PublishedLanguage/Commands/SendEmail.cs @@ -1,4 +1,6 @@ -using MediatR; +// Copyright (c) 2023 Tudor Stanciu + +using MediatR; using System.Collections.Generic; namespace Correo.PublishedLanguage.Commands diff --git a/src/Correo.PublishedLanguage/Correo.PublishedLanguage.csproj b/src/Correo.PublishedLanguage/Correo.PublishedLanguage.csproj index b7b27e4..ee604d9 100644 --- a/src/Correo.PublishedLanguage/Correo.PublishedLanguage.csproj +++ b/src/Correo.PublishedLanguage/Correo.PublishedLanguage.csproj @@ -1,17 +1,34 @@ - + - net6.0 - 1.0.1 + net8.0 + 1.1.0 + 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. + https://lab.code-rove.com/gitea/tudor.stanciu/correo + https://lab.code-rove.com/gitea/tudor.stanciu/correo + Git + $([System.IO.File]::ReadAllText("$(MSBuildProjectDirectory)/ReleaseNotes.txt")) correo.png - Correo published language + README.md + Toodle HomeLab + Toodle Correo + Correo HomeLab CodeRove + Apache-2.0 - + + + true + / + + + True + \ + True \ diff --git a/src/Correo.PublishedLanguage/Events/Records.cs b/src/Correo.PublishedLanguage/Events/Records.cs index 87ee821..0634cc9 100644 --- a/src/Correo.PublishedLanguage/Events/Records.cs +++ b/src/Correo.PublishedLanguage/Events/Records.cs @@ -1,4 +1,6 @@ -using MediatR; +// Copyright (c) 2023 Tudor Stanciu + +using MediatR; namespace Correo.PublishedLanguage.Events { diff --git a/src/Correo.PublishedLanguage/README.md b/src/Correo.PublishedLanguage/README.md new file mode 100644 index 0000000..8bd63f2 --- /dev/null +++ b/src/Correo.PublishedLanguage/README.md @@ -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 + + + + + + + + +``` + +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. diff --git a/src/Correo.PublishedLanguage/ReleaseNotes.txt b/src/Correo.PublishedLanguage/ReleaseNotes.txt new file mode 100644 index 0000000..92cfc63 --- /dev/null +++ b/src/Correo.PublishedLanguage/ReleaseNotes.txt @@ -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 \ No newline at end of file diff --git a/src/Correo.SendGrid/Correo.SendGrid.csproj b/src/Correo.SendGrid/Correo.SendGrid.csproj index 92a48f4..4fcae99 100644 --- a/src/Correo.SendGrid/Correo.SendGrid.csproj +++ b/src/Correo.SendGrid/Correo.SendGrid.csproj @@ -1,7 +1,7 @@  - net6.0 + net8.0 diff --git a/src/Correo.SendGrid/DependencyInjectionExtensions.cs b/src/Correo.SendGrid/DependencyInjectionExtensions.cs index c6b1fbe..13b9e08 100644 --- a/src/Correo.SendGrid/DependencyInjectionExtensions.cs +++ b/src/Correo.SendGrid/DependencyInjectionExtensions.cs @@ -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(); } } -} \ No newline at end of file +} diff --git a/src/Correo.SendGrid/Extensions/ModelExtensions.cs b/src/Correo.SendGrid/Extensions/ModelExtensions.cs index 85e2645..7b4d599 100644 --- a/src/Correo.SendGrid/Extensions/ModelExtensions.cs +++ b/src/Correo.SendGrid/Extensions/ModelExtensions.cs @@ -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; diff --git a/src/Correo.SendGrid/Models/ErrorModels.cs b/src/Correo.SendGrid/Models/ErrorModels.cs index b950e2b..0db64f4 100644 --- a/src/Correo.SendGrid/Models/ErrorModels.cs +++ b/src/Correo.SendGrid/Models/ErrorModels.cs @@ -1,4 +1,6 @@ -namespace Correo.SendGrid.Models +// Copyright (c) 2023 Tudor Stanciu + +namespace Correo.SendGrid.Models { internal record Error { diff --git a/src/Correo.SendGrid/Models/SendGridOptions.cs b/src/Correo.SendGrid/Models/SendGridOptions.cs index 028be47..1c62abb 100644 --- a/src/Correo.SendGrid/Models/SendGridOptions.cs +++ b/src/Correo.SendGrid/Models/SendGridOptions.cs @@ -1,4 +1,6 @@ -namespace Correo.SendGrid.Models +// Copyright (c) 2023 Tudor Stanciu + +namespace Correo.SendGrid.Models { internal record SendGridOptions { diff --git a/src/Correo.SendGrid/SendGridService.cs b/src/Correo.SendGrid/SendGridService.cs index 49755bc..af86168 100644 --- a/src/Correo.SendGrid/SendGridService.cs +++ b/src/Correo.SendGrid/SendGridService.cs @@ -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; diff --git a/src/Correo/Controllers/MailerController.cs b/src/Correo/Controllers/MailerController.cs index a5a4130..ee1ded8 100644 --- a/src/Correo/Controllers/MailerController.cs +++ b/src/Correo/Controllers/MailerController.cs @@ -1,4 +1,6 @@ -using AutoMapper; +// Copyright (c) 2023 Tudor Stanciu + +using AutoMapper; using Correo.Application.CommandHandlers; using Correo.PublishedLanguage.Commands; using MediatR; diff --git a/src/Correo/Controllers/SystemController.cs b/src/Correo/Controllers/SystemController.cs index 555d259..57adf04 100644 --- a/src/Correo/Controllers/SystemController.cs +++ b/src/Correo/Controllers/SystemController.cs @@ -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); } } -} \ No newline at end of file +} diff --git a/src/Correo/Correo.csproj b/src/Correo/Correo.csproj index c33b1a1..7cb4702 100644 --- a/src/Correo/Correo.csproj +++ b/src/Correo/Correo.csproj @@ -1,14 +1,12 @@  - net6.0 + net8.0 Linux ..\.. - - diff --git a/src/Correo/Dockerfile b/src/Correo/Dockerfile index 5301e0a..3d1f4e2 100644 --- a/src/Correo/Dockerfile +++ b/src/Correo/Dockerfile @@ -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 diff --git a/src/Correo/Extensions/DataTypeExtensions.cs b/src/Correo/Extensions/DataTypeExtensions.cs index c470335..2152efc 100644 --- a/src/Correo/Extensions/DataTypeExtensions.cs +++ b/src/Correo/Extensions/DataTypeExtensions.cs @@ -1,4 +1,6 @@ -using System; +// Copyright (c) 2023 Tudor Stanciu + +using System; namespace Correo.Extensions { diff --git a/src/Correo/Extensions/LoggingExtensions.cs b/src/Correo/Extensions/LoggingExtensions.cs index f321566..f71566a 100644 --- a/src/Correo/Extensions/LoggingExtensions.cs +++ b/src/Correo/Extensions/LoggingExtensions.cs @@ -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; diff --git a/src/Correo/Extensions/MessagingExtensions.cs b/src/Correo/Extensions/MessagingExtensions.cs index a70d379..e7994e2 100644 --- a/src/Correo/Extensions/MessagingExtensions.cs +++ b/src/Correo/Extensions/MessagingExtensions.cs @@ -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; diff --git a/src/Correo/Extensions/SmtpExtensions.cs b/src/Correo/Extensions/SmtpExtensions.cs index 0b394d0..ba32857 100644 --- a/src/Correo/Extensions/SmtpExtensions.cs +++ b/src/Correo/Extensions/SmtpExtensions.cs @@ -1,4 +1,6 @@ -using Correo.Mailgun; +// Copyright (c) 2023 Tudor Stanciu + +using Correo.Mailgun; using Correo.MailKit; using Correo.NetSmtpClient; using Correo.SendGrid; diff --git a/src/Correo/Extensions/StartupExtensions.cs b/src/Correo/Extensions/StartupExtensions.cs index 0d83145..644e17a 100644 --- a/src/Correo/Extensions/StartupExtensions.cs +++ b/src/Correo/Extensions/StartupExtensions.cs @@ -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()); services.AddScoped(typeof(IPipelineBehavior<,>), typeof(RequestPreProcessorBehavior<,>)); // Messaging diff --git a/src/Correo/Middlewares/SubscriberLoggingMiddleware.cs b/src/Correo/Middlewares/SubscriberLoggingMiddleware.cs index d6a9cd5..909c7bf 100644 --- a/src/Correo/Middlewares/SubscriberLoggingMiddleware.cs +++ b/src/Correo/Middlewares/SubscriberLoggingMiddleware.cs @@ -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; diff --git a/src/Correo/Program.cs b/src/Correo/Program.cs index 7bd5531..48e0b09 100644 --- a/src/Correo/Program.cs +++ b/src/Correo/Program.cs @@ -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 } } } -} \ No newline at end of file +}