tests OK
This commit is contained in:
parent
5620213cf5
commit
6cc0c519d2
15 changed files with 81 additions and 187 deletions
|
|
@ -47,9 +47,9 @@ namespace Yavsc.Services
|
|||
/// <returns>a MessageWithPayloadResponse,
|
||||
/// <c>bool somethingsent = (response.failure == 0 && 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
|
||||
);
|
||||
|
|
|
|||
|
|
@ -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()}");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -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; }
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue