This commit is contained in:
Paul Schneider 2026-04-20 00:35:51 +01:00
commit 6cc0c519d2
15 changed files with 81 additions and 187 deletions

View file

@ -47,9 +47,9 @@ namespace Yavsc.Services
/// <returns>a MessageWithPayloadResponse,
/// <c>bool somethingsent = (response.failure == 0 &amp;&amp; response.success > 0)</c>
/// </returns>
public async Task SendEmailAsync(string email, string subject, string htmlMessage)
public Task SendEmailAsync(string email, string subject, string htmlMessage)
{
await SendEmailAsync("", email, subject, htmlMessage);
return SendEmailAsync("", email, subject, htmlMessage);
}
public async Task<string> SendEmailAsync(string name, string email, string subject, string htmlMessage)
@ -71,8 +71,9 @@ namespace Yavsc.Services
);
using (SmtpClient sc = new())
{
sc.Timeout = 30000;
sc.Connect(
smtpSettings.Server,
smtpSettings.Host,
smtpSettings.Port,
SecureSocketOptions.Auto
);

View file

@ -1,30 +0,0 @@
using System;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Identity.UI.Services;
using Microsoft.Extensions.Logging;
using Yavsc.Interface;
namespace Yavsc.Services
{
public class TestMailSender : ITrueEmailSender, IEmailSender
{
private readonly ILogger<TestMailSender> logger;
public TestMailSender(ILoggerFactory loggerFactory)
{
logger = loggerFactory.CreateLogger<TestMailSender>();
}
public Task SendEmailAsync(string email, string subject, string htmlMessage)
{
logger.LogInformation("[TestMailSender] SendEmailAsync to {Email} subject={Subject}", email, subject);
return Task.CompletedTask;
}
public Task<string> SendEmailAsync(string name, string email, string subject, string htmlMessage)
{
logger.LogInformation("[TestMailSender] SendEmailAsync to {Email} subject={Subject} name={Name}", email, subject, name);
return Task.FromResult($"test-message-{Guid.NewGuid()}");
}
}
}

View file

@ -2,17 +2,13 @@ namespace Yavsc.Settings
{
public class SmtpSettings
{
public string Server { get; set; }
public string Host
{
get => Server;
set => Server = value;
get ;
set ;
}
public int Port { get; set; }
public string SenderName { get; set; }
public string SenderEmail { get; set; }
public string UserName { get; set; }
public string Password { get; set; }
}