Tudor Stanciu 2023-01-30 19:23:54 +02:00
commit 697f139625
6 changed files with 23 additions and 13 deletions

View File

@ -1,7 +1,7 @@
<Project> <Project>
<Import Project="dependencies.props" /> <Import Project="dependencies.props" />
<PropertyGroup> <PropertyGroup>
<Version>1.0.0</Version> <Version>1.0.1</Version>
<Authors>Tudor Stanciu</Authors> <Authors>Tudor Stanciu</Authors>
<Company>STA</Company> <Company>STA</Company>
<PackageTags>Correo</PackageTags> <PackageTags>Correo</PackageTags>

View File

@ -57,17 +57,27 @@ For this integration, the setup is very simple. All you need is an API Key gener
} }
``` ```
## Database ## Logging
The database is SQLite. It is created automatically at the first start of the service, if it is missing. The path where the database is stored can be configured as follows: 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:
``` ```
"Workspace": "workspace", "Logs": {
"ConnectionStrings": { "File": {
"DatabaseConnection": "Data Source={Workspace}\\correo.db" "Enabled": false,
"Path": "logs/log.txt"
},
"Postgres": {
"Enabled": false,
"Connection": "Host=<host>;Port=5432;User ID=<user>;Password=<password>;Database=<database>;"
},
"Seq": {
"Enabled": false,
"Url": "",
"ApiKey": ""
}
} }
``` ```
For the moment, the only purpose of the database is to store the logs generated by Serilog.
## Hosting ## 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. 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.

View File

@ -11,9 +11,9 @@ namespace Correo.Abstractions.Extensions
public static string Log(this EmailMessage message) public static string Log(this EmailMessage message)
{ {
var msg = $"Email sent: Subject: {message.Subject}; From: {message.From.Address}; To: {message.To.Log()};"; var msg = $"Email sent: Subject: {message.Subject}; From: {message.From.Address}; To: {message.To.Log()};";
if (message.Cc != null) if (message.Cc != null && message.Cc.Any())
msg += $" Cc: {message.Cc.Log()};"; msg += $" Cc: {message.Cc.Log()};";
if (message.Bcc != null) if (message.Bcc != null && message.Bcc.Any())
msg += $" Bcc: {message.Bcc.Log()};"; msg += $" Bcc: {message.Bcc.Log()};";
return msg; return msg;
} }

View File

@ -7,7 +7,7 @@ namespace Correo.Mailgun.Extensions
internal static class ModelExtensions internal static class ModelExtensions
{ {
public static string ToMailgunAddress(this EmailMessage.MailAddress address) public static string ToMailgunAddress(this EmailMessage.MailAddress address)
=> $"{address.DisplayName} <{address.Address}>"; => string.IsNullOrEmpty(address.DisplayName) ? address.Address : $"{address.DisplayName} <{address.Address}>";
public static string ToMailgunAddresses(this IEnumerable<EmailMessage.MailAddress> addresses) public static string ToMailgunAddresses(this IEnumerable<EmailMessage.MailAddress> addresses)
{ {

View File

@ -13,6 +13,6 @@ namespace Correo.PublishedLanguage.Commands
public IEnumerable<MailAddress> Bcc { get; init; } public IEnumerable<MailAddress> Bcc { get; init; }
public bool IsBodyHtml { get; init; } public bool IsBodyHtml { get; init; }
public record MailAddress(string Address, string DisplayName); public record MailAddress(string Address, string DisplayName = null);
} }
} }

View File

@ -2,7 +2,7 @@
<PropertyGroup> <PropertyGroup>
<TargetFramework>net6.0</TargetFramework> <TargetFramework>net6.0</TargetFramework>
<Version>1.0.0</Version> <Version>1.0.1</Version>
<PackageIcon>correo.png</PackageIcon> <PackageIcon>correo.png</PackageIcon>
<Description>Correo published language</Description> <Description>Correo published language</Description>
</PropertyGroup> </PropertyGroup>