Update Email module

Fixes #3711
This commit is contained in:
Sipke Schoorstra 2023-04-18 22:14:18 +02:00
parent 8145e847e9
commit 31d24034d1
10 changed files with 45 additions and 16 deletions

View file

@ -85,6 +85,12 @@ services:
- "5601:5601"
depends_on:
- elasticsearch
smtp4dev:
image: rnwood/smtp4dev:3.1.3-ci20211206101
ports:
- "3000:80"
- "2525:25"
networks:
consul:

View file

@ -10,6 +10,7 @@
<ItemGroup>
<ProjectReference Include="..\..\bundles\Elsa\Elsa.csproj" />
<ProjectReference Include="..\..\modules\Elsa.Email\Elsa.Email.csproj" />
<ProjectReference Include="..\..\modules\Elsa.Hangfire\Elsa.Hangfire.csproj" />
<ProjectReference Include="..\..\modules\Elsa.Http\Elsa.Http.csproj" />
<ProjectReference Include="..\..\modules\Elsa.Identity\Elsa.Identity.csproj" />

View file

@ -40,6 +40,7 @@ services
.UseJavaScript()
.UseLiquid()
.UseHttp()
.UseEmail(email => email.ConfigureOptions = options => configuration.GetSection("Smtp").Bind(options))
);
services.AddHealthChecks();

View file

@ -17,5 +17,10 @@
"Tokens": {
"SigningKey": "secret-signing-key"
}
},
"Smtp": {
"Host": "localhost",
"Port": 2525,
"DefaultSender": "noreply@crmservices.com"
}
}

View file

@ -10,6 +10,7 @@
<ItemGroup>
<ProjectReference Include="..\..\modules\Elsa.Elasticsearch\Elsa.Elasticsearch.csproj" />
<ProjectReference Include="..\..\modules\Elsa.Email\Elsa.Email.csproj" />
<ProjectReference Include="..\..\modules\Elsa.EntityFrameworkCore.PostgreSql\Elsa.EntityFrameworkCore.PostgreSql.csproj" />
<ProjectReference Include="..\..\modules\Elsa.EntityFrameworkCore.Sqlite\Elsa.EntityFrameworkCore.Sqlite.csproj" />
<ProjectReference Include="..\..\modules\Elsa.EntityFrameworkCore\Elsa.EntityFrameworkCore.csproj" />

View file

@ -47,6 +47,7 @@ services
.UseJavaScript()
.UseLiquid()
.UseHttp()
.UseEmail(email => email.ConfigureOptions = options => configuration.GetSection("Smtp").Bind(options))
);
services.Configure<JintOptions>(options => options.AllowClrAccess = true);

View file

@ -15,6 +15,11 @@
"ConnectionStrings": {
"Sqlite": "Data Source=elsa.sqlite.db;Cache=Shared;"
},
"Smtp": {
"Host": "localhost",
"Port": 2525,
"DefaultSender": "noreply@crmservices.com"
},
"Identity": {
"Tokens": {
"SigningKey": "secret-signing-key",

View file

@ -1,6 +1,8 @@
using System.Collections;
using System.Runtime.CompilerServices;
using System.Text;
using System.Text.Json;
using System.Text.Json.Serialization;
using Elsa.Email.Contracts;
using Elsa.Email.Models;
using Elsa.Email.Options;
@ -20,11 +22,22 @@ namespace Elsa.Email.Activities;
[Activity("Email", "Send an email message.", Kind = ActivityKind.Task)]
public class SendEmail : Activity
{
/// <inheritdoc />
public SendEmail([CallerFilePath] string? source = default, [CallerLineNumber] int? line = default) : base(source, line)
{
}
/// <inheritdoc />
[JsonConstructor]
public SendEmail()
{
}
/// <summary>
/// The sender's email address.
/// </summary>
[Input(Description = "The sender's email address.")]
public Input<string?> From { get; set; }
public Input<string?> From { get; set; } = default!;
[Input(Description = "The recipients email addresses.", UIHint = InputUIHints.MultiText)]
public Input<ICollection<string>> To { get; set; } = default!;

View file

@ -1,6 +1,7 @@
using Elsa.Email.Contracts;
using Elsa.Email.Options;
using Elsa.Email.Services;
using Elsa.Extensions;
using Elsa.Features.Abstractions;
using Elsa.Features.Services;
using Microsoft.Extensions.DependencyInjection;
@ -27,11 +28,18 @@ public class EmailFeature : FeatureBase
/// </summary>
public Action<IServiceProvider, HttpClient> ConfigureDownloaderHttpClient { get; set; } = (_, _) => { };
/// <inheritdoc />
public override void Configure()
{
Module.AddActivitiesFrom<EmailFeature>();
}
/// <inheritdoc />
public override void Apply()
{
Services.Configure(ConfigureOptions);
Services.AddSingleton<ISmtpService, MailKitSmtpService>();
Services.AddHttpClient<IDownloader, DefaultDownloader>(ConfigureDownloaderHttpClient);
Services
.Configure(ConfigureOptions)
.AddSingleton<ISmtpService, MailKitSmtpService>()
.AddHttpClient<IDownloader, DefaultDownloader>(ConfigureDownloaderHttpClient);
}
}

View file

@ -1,12 +0,0 @@
version: '3.9'
services:
smtp4dev:
image: rnwood/smtp4dev:3.1.3-ci20211206101
ports:
- "3000:80"
- "2525:25"
volumes:
mssql-azuresql-edge-data: