1
0
mirror of https://github.com/Sonarr/Sonarr.git synced 2024-12-14 11:23:42 +02:00

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

View File

@ -26,16 +26,33 @@ public EmailService(Logger logger)
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 @@ public void SendEmail(EmailSettings settings, string subject, string body, bool
_logger.Debug(ex, ex.Message);
throw;
}
_logger.Debug("Finished sending email '{0}'", subject);
}
private void Send(MimeMessage email, EmailSettings settings)