diff --git a/.github/workflows/dotnet-core.yml b/.github/workflows/dotnet-core.yml
index f3c2b56..091598b 100644
--- a/.github/workflows/dotnet-core.yml
+++ b/.github/workflows/dotnet-core.yml
@@ -2,7 +2,7 @@ name: Build & Test
on:
pull_request:
- branches: [master]
+ branches: [main]
jobs:
build:
diff --git a/.gitignore b/.gitignore
index c72a37e..7d9fe0a 100644
--- a/.gitignore
+++ b/.gitignore
@@ -246,3 +246,5 @@ ModelManifest.xml
# Verify test files
*.received.txt
+
+.env
diff --git a/FluentEmail.sln b/FluentEmail.sln
index 10d31e5..e13c173 100644
--- a/FluentEmail.sln
+++ b/FluentEmail.sln
@@ -4,6 +4,9 @@ Microsoft Visual Studio Solution File, Format Version 12.00
VisualStudioVersion = 17.4.33205.214
MinimumVisualStudioVersion = 10.0.40219.1
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "test", "test", "{6DC215BD-05EF-49A6-ADBE-8AE399952EEC}"
+ ProjectSection(SolutionItems) = preProject
+ test\Directory.Build.props = test\Directory.Build.props
+ EndProjectSection
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{D5C44238-0312-43F8-9705-EACFB039A48C}"
EndProject
diff --git a/FluentEmail.sln.DotSettings b/FluentEmail.sln.DotSettings
new file mode 100644
index 0000000..248dd01
--- /dev/null
+++ b/FluentEmail.sln.DotSettings
@@ -0,0 +1,4 @@
+
+ True
+ True
+ True
\ No newline at end of file
diff --git a/src/FluentEmail.Core/FluentEmail.Core.csproj b/src/FluentEmail.Core/FluentEmail.Core.csproj
index 5bba4ed..645edc1 100644
--- a/src/FluentEmail.Core/FluentEmail.Core.csproj
+++ b/src/FluentEmail.Core/FluentEmail.Core.csproj
@@ -20,7 +20,7 @@
-
+
diff --git a/src/Senders/FluentEmail.Mailtrap/MailtrapSender.cs b/src/Senders/FluentEmail.Mailtrap/MailtrapSender.cs
index 1e8484c..989364e 100644
--- a/src/Senders/FluentEmail.Mailtrap/MailtrapSender.cs
+++ b/src/Senders/FluentEmail.Mailtrap/MailtrapSender.cs
@@ -19,10 +19,10 @@ namespace FluentEmail.Mailtrap
///
public class MailtrapSender : IMailtrapSender, IDisposable
{
- private const string URL = "https://send.api.mailtrap.io/api/send";
private readonly SmtpClient _smtpClient;
private static readonly int[] ValidPorts = {25,587, 2525};
private readonly string _apiKey;
+ private readonly string _apiHost;
///
/// Creates a sender that uses the given Mailtrap credentials, but does not dispose it.
@@ -31,7 +31,7 @@ public class MailtrapSender : IMailtrapSender, IDisposable
/// Password of your mailtrap.io SMTP inbox
/// Host address for the Mailtrap.io SMTP inbox
/// Port for the Mailtrap.io SMTP server. Accepted values are 25, 465 or 2525.
- public MailtrapSender(string userName, string password, string host = "smtp.mailtrap.io", int? port = null)
+ public MailtrapSender(string userName, string password, string host = "smtp.mailtrap.io", int? port = null, string apiHost = "https://send.api.mailtrap.io/api/send")
{
if (string.IsNullOrWhiteSpace(userName))
throw new ArgumentException("Mailtrap UserName needs to be supplied", nameof(userName));
@@ -42,6 +42,7 @@ public MailtrapSender(string userName, string password, string host = "smtp.mail
if (port.HasValue && !ValidPorts.Contains(port.Value))
throw new ArgumentException("Mailtrap Port needs to be either 25, 465 or 2525", nameof(port));
_apiKey = password;
+ _apiHost = apiHost;
_smtpClient = new SmtpClient(host, port.GetValueOrDefault(587))
{
Credentials = new NetworkCredential(userName, password),
@@ -66,12 +67,12 @@ public Task SendAsync(IFluentEmail email, CancellationToken? token
public async Task SendWithTemplateAsync(IFluentEmail email, string templateName, object templateData, CancellationToken? token = null)
{
token?.ThrowIfCancellationRequested();
- using (var httpClient = new HttpClient { BaseAddress = new Uri(URL) })
+ using (var httpClient = new HttpClient { BaseAddress = new Uri(_apiHost) })
{
httpClient.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", _apiKey);
httpClient.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
var jsonContent = HttpClientHelpers.GetJsonBody(BuildMailtrapParameters(email, templateName, templateData));
- var response = await httpClient.Post(URL, jsonContent);
+ var response = await httpClient.Post(_apiHost, jsonContent);
var result = new SendResponse { MessageId = response.Data?.Id };
if (!response.Success)
{
diff --git a/test/Directory.Build.props b/test/Directory.Build.props
index dc6b5a1..5cde688 100644
--- a/test/Directory.Build.props
+++ b/test/Directory.Build.props
@@ -4,11 +4,10 @@
false
true
net8.0
- Exe
-
+
runtime; build; native; contentfiles; analyzers; buildtransitive
diff --git a/test/FluentEmail.Bootstrap.Tests/BootstrapTests.cs b/test/FluentEmail.Bootstrap.Tests/BootstrapTests.cs
index cea8e5d..5660afd 100644
--- a/test/FluentEmail.Bootstrap.Tests/BootstrapTests.cs
+++ b/test/FluentEmail.Bootstrap.Tests/BootstrapTests.cs
@@ -4,6 +4,7 @@
using System;
using System.Threading.Tasks;
using FluentEmail.Core;
+using FluentEmail.Core.Interfaces;
using FluentEmail.Liquid;
using Fluid;
using Microsoft.Extensions.FileProviders;
@@ -25,11 +26,9 @@ public BootstrapTests()
{
_settings.ScrubLinesContaining("Compiled with Bootstrap Email DotNet");
_settings.DisableDiff();
- // default to have no file provider, only required when layout files are in use
- SetupRenderer();
}
- private static void SetupRenderer(
+ private static ITemplateRenderer SetupRenderer(
IFileProvider fileProvider = null,
Action configureTemplateContext = null)
{
@@ -38,7 +37,7 @@ private static void SetupRenderer(
FileProvider = fileProvider,
ConfigureTemplateContext = configureTemplateContext,
};
- Email.DefaultRenderer = new LiquidRenderer(Options.Create(options));
+ return new LiquidRenderer(Options.Create(options));
}
[Fact]
@@ -51,11 +50,13 @@ public Task CompileBootstrap_Compiles()