Debug logging for email notifications

ref #4348
This commit is contained in:
Taloth Saldono 2021-03-06 00:14:50 +01:00
parent 13ff2d4c70
commit ab4f57f2fa
1 changed files with 23 additions and 4 deletions

View File

@ -26,16 +26,33 @@ namespace NzbDrone.Core.Notifications.Email
public void SendEmail(EmailSettings settings, string subject, string body, bool htmlBody = false)
{
var email = new MimeMessage();
email.From.Add(MailboxAddress.Parse(settings.From));
email.To.Add(MailboxAddress.Parse(settings.To));
try
{
email.From.Add(MailboxAddress.Parse(settings.From));
}
catch (Exception ex)
{
_logger.Error(ex, "From email address '{0}' invalid", settings.From);
}
try
{
email.To.Add(MailboxAddress.Parse(settings.To));
}
catch (Exception ex)
{
_logger.Error(ex, "To email address '{0}' invalid", settings.To);
}
email.Subject = subject;
email.Body = new TextPart(htmlBody ? "html" : "plain")
{
Text = body
};
_logger.Debug("Sending email '{0}'", subject);
try
{
Send(email, settings);
@ -46,6 +63,8 @@ namespace NzbDrone.Core.Notifications.Email
_logger.Debug(ex, ex.Message);
throw;
}
_logger.Debug("Finished sending email '{0}'", subject);
}
private void Send(MimeMessage email, EmailSettings settings)