This commit is contained in:
Michael 2017-04-04 21:05:23 -04:00
parent a797d998fe
commit 3737da45ca

View file

@ -25,6 +25,7 @@ public async Task SendAsync(IdentityMessage message)
var siteConfig = new ApplicationDbContext().Configs.FirstOrDefault(); var siteConfig = new ApplicationDbContext().Configs.FirstOrDefault();
var smtp = new SmtpClient(siteConfig.SMTPServer, siteConfig.SMTPPort); var smtp = new SmtpClient(siteConfig.SMTPServer, siteConfig.SMTPPort);
smtp.UseDefaultCredentials = false;
if (siteConfig.UseTLSEncryption) if (siteConfig.UseTLSEncryption)
smtp.EnableSsl = true; //This is misleading... We want TLS but all we have is SSL. Oh well. smtp.EnableSsl = true; //This is misleading... We want TLS but all we have is SSL. Oh well.
smtp.UseDefaultCredentials = false; smtp.UseDefaultCredentials = false;
@ -38,6 +39,7 @@ public async Task SendAsync(IdentityMessage message)
<p>" + CommonMark.CommonMarkConverter.Convert(message.Body) + "</p>"; <p>" + CommonMark.CommonMarkConverter.Convert(message.Body) + "</p>";
sMsg.Subject = $"[{siteConfig.SiteName}] " + message.Subject; sMsg.Subject = $"[{siteConfig.SiteName}] " + message.Subject;
sMsg.IsBodyHtml = true; sMsg.IsBodyHtml = true;
smtp.DeliveryMethod = SmtpDeliveryMethod.Network;
var db = new ApplicationDbContext(); var db = new ApplicationDbContext();
db.AuditLogs.Add(new AuditLog("system", AuditLogLevel.Admin, $"Email sending...<br/><br/><strong>To:</strong> {sMsg.To}<br/><strong>Subject:</strong><br/>{sMsg.Subject}")); db.AuditLogs.Add(new AuditLog("system", AuditLogLevel.Admin, $"Email sending...<br/><br/><strong>To:</strong> {sMsg.To}<br/><strong>Subject:</strong><br/>{sMsg.Subject}"));
db.SaveChanges(); db.SaveChanges();