Merge pull request #10998 from umbraco/v9/bugfix/email-sending-metadata

Updates email sender to have some metadata
This commit is contained in:
Warren Buckley
2021-09-01 10:27:29 +01:00
committed by GitHub
9 changed files with 35 additions and 17 deletions

View File

@@ -49,16 +49,16 @@ namespace Umbraco.Cms.Infrastructure.Mail
/// </summary>
/// <param name="message"></param>
/// <returns></returns>
public async Task SendAsync(EmailMessage message) => await SendAsyncInternal(message, false);
public async Task SendAsync(EmailMessage message, string emailType) => await SendAsyncInternal(message, emailType, false);
public async Task SendAsync(EmailMessage message, bool enableNotification) =>
await SendAsyncInternal(message, enableNotification);
public async Task SendAsync(EmailMessage message, string emailType, bool enableNotification) =>
await SendAsyncInternal(message, emailType, enableNotification);
private async Task SendAsyncInternal(EmailMessage message, bool enableNotification)
private async Task SendAsyncInternal(EmailMessage message, string emailType, bool enableNotification)
{
if (enableNotification)
{
var notification = new SendEmailNotification(message.ToNotificationEmail(_globalSettings.Smtp?.From));
var notification = new SendEmailNotification(message.ToNotificationEmail(_globalSettings.Smtp?.From), emailType);
await _eventAggregator.PublishAsync(notification);
// if a handler handled sending the email then don't continue.

View File

@@ -1,4 +1,4 @@
using System;
using System;
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.Globalization;
@@ -519,7 +519,7 @@ namespace Umbraco.Cms.Core.Services.Implement
{
try
{
_emailSender.SendAsync(request.Mail).GetAwaiter().GetResult();
_emailSender.SendAsync(request.Mail, Constants.Web.EmailTypes.Notification).GetAwaiter().GetResult();
_logger.LogDebug("Notification '{Action}' sent to {Username} ({Email})", request.Action, request.UserName, request.Email);
}
catch (Exception ex)