From 0d73c49fed8f3628d0ec80e6a876d6f54df2dd63 Mon Sep 17 00:00:00 2001 From: Michael Date: Thu, 18 May 2017 12:50:42 -0400 Subject: [PATCH] new mail backend --- Project-Unite/App_Start/IdentityConfig.cs | 51 ++- Project-Unite/Project-Unite.csproj | 368 ++++++++++++++++++++++ Project-Unite/packages.config | 2 + 3 files changed, 391 insertions(+), 30 deletions(-) diff --git a/Project-Unite/App_Start/IdentityConfig.cs b/Project-Unite/App_Start/IdentityConfig.cs index b9ca64b..dc36eb3 100644 --- a/Project-Unite/App_Start/IdentityConfig.cs +++ b/Project-Unite/App_Start/IdentityConfig.cs @@ -13,45 +13,36 @@ using Microsoft.Owin; using Microsoft.Owin.Security; using Project_Unite.Models; +using Reachmail.Easysmtp.Post.Request; +using Reachmail.Easysmtp.Post.Response; namespace Project_Unite { public class EmailService : IIdentityMessageService { - public async Task SendAsync(IdentityMessage msg) + public Task SendAsync(IdentityMessage msg) { - try - { - var siteConfig = new ApplicationDbContext().Configs.FirstOrDefault(); - var message = new MailMessage(); - message.To.Add(new MailAddress(msg.Destination)); - message.Subject = "[ShiftOS] " + msg.Subject; - message.Body = msg.Body; - message.IsBodyHtml = true; + var siteConfig = new ApplicationDbContext().Configs.First(); + var reachmail = Reachmail.Api.Create(siteConfig.SMTPUsername); - using (var smtp = new SmtpClient()) - { - var credential = new NetworkCredential - { - UserName = siteConfig.SMTPUsername, - Password = siteConfig.SMTPPassword - }; - smtp.Credentials = credential; - smtp.Host = siteConfig.SMTPServer; - smtp.Port = siteConfig.SMTPPort; - smtp.EnableSsl = siteConfig.UseTLSEncryption; - await smtp.SendMailAsync(message); - } - } - catch (Exception ex) + var request = new DeliveryRequest { - var db = new ApplicationDbContext(); - db.AuditLogs.Add(new AuditLog("system", AuditLogLevel.Admin, $@"Failed to send email: - -{ex}")); - await db.SaveChangesAsync(); + FromAddress = "sys@michaeltheshifter.me", + Recipients = new Recipients { + new Recipient { + Address = msg.Destination } - return; + }, + Subject = "[ShiftOS] " + msg.Subject, + BodyText = msg.Body, + BodyHtml = "html", + Tracking = true, + FooterAddress = "sys@michaeltheshifter.me", + SignatureDomain = "getshiftos.ml" + }; + + var result = reachmail.Easysmtp.Post(request); + return Task.FromResult(result); } diff --git a/Project-Unite/Project-Unite.csproj b/Project-Unite/Project-Unite.csproj index ac18c7e..dd1e06a 100644 --- a/Project-Unite/Project-Unite.csproj +++ b/Project-Unite/Project-Unite.csproj @@ -130,6 +130,374 @@ ..\packages\Nito.AsyncEx.3.0.1\lib\net45\Nito.AsyncEx.Enlightenment.dll True + + ..\packages\reachmail.2.0.0.87\lib\Reachmail.dll + True + + + ..\packages\SecureBlackbox.15.1.300\lib\net451\SecureBlackbox.dll + True + + + ..\packages\SecureBlackbox.15.1.300\lib\net451\SecureBlackbox.ASiC.dll + True + + + ..\packages\SecureBlackbox.15.1.300\lib\net451\SecureBlackbox.ASiC.Async.dll + True + + + ..\packages\SecureBlackbox.15.1.300\lib\net451\SecureBlackbox.Async.dll + True + + + ..\packages\SecureBlackbox.15.1.300\lib\net451\SecureBlackbox.Cloud.dll + True + + + ..\packages\SecureBlackbox.15.1.300\lib\net451\SecureBlackbox.Cloud.Async.dll + True + + + ..\packages\SecureBlackbox.15.1.300\lib\net451\SecureBlackbox.DAVClient.dll + True + + + ..\packages\SecureBlackbox.15.1.300\lib\net451\SecureBlackbox.DAVClient.Async.dll + True + + + ..\packages\SecureBlackbox.15.1.300\lib\net451\SecureBlackbox.DAVCommon.dll + True + + + ..\packages\SecureBlackbox.15.1.300\lib\net451\SecureBlackbox.DAVCommon.Async.dll + True + + + ..\packages\SecureBlackbox.15.1.300\lib\net451\SecureBlackbox.DAVIISServer.dll + True + + + ..\packages\SecureBlackbox.15.1.300\lib\net451\SecureBlackbox.DAVServer.dll + True + + + ..\packages\SecureBlackbox.15.1.300\lib\net451\SecureBlackbox.DAVServer.Async.dll + True + + + ..\packages\SecureBlackbox.15.1.300\lib\net451\SecureBlackbox.DC.dll + True + + + ..\packages\SecureBlackbox.15.1.300\lib\net451\SecureBlackbox.DC.Async.dll + True + + + ..\packages\SecureBlackbox.15.1.300\lib\net451\SecureBlackbox.DCPKI.dll + True + + + ..\packages\SecureBlackbox.15.1.300\lib\net451\SecureBlackbox.DCPKI.Async.dll + True + + + ..\packages\SecureBlackbox.15.1.300\lib\net451\SecureBlackbox.EDI.dll + True + + + ..\packages\SecureBlackbox.15.1.300\lib\net451\SecureBlackbox.EDI.Async.dll + True + + + ..\packages\SecureBlackbox.15.1.300\lib\net451\SecureBlackbox.FTPS.dll + True + + + ..\packages\SecureBlackbox.15.1.300\lib\net451\SecureBlackbox.FTPS.Async.dll + True + + + ..\packages\SecureBlackbox.15.1.300\lib\net451\SecureBlackbox.FTPSServer.dll + True + + + ..\packages\SecureBlackbox.15.1.300\lib\net451\SecureBlackbox.FTPSServer.Async.dll + True + + + ..\packages\SecureBlackbox.15.1.300\lib\net451\SecureBlackbox.HTTP.dll + True + + + ..\packages\SecureBlackbox.15.1.300\lib\net451\SecureBlackbox.HTTP.Async.dll + True + + + ..\packages\SecureBlackbox.15.1.300\lib\net451\SecureBlackbox.HTTPCommon.dll + True + + + ..\packages\SecureBlackbox.15.1.300\lib\net451\SecureBlackbox.HTTPCommon.Async.dll + True + + + ..\packages\SecureBlackbox.15.1.300\lib\net451\SecureBlackbox.HTTPServer.dll + True + + + ..\packages\SecureBlackbox.15.1.300\lib\net451\SecureBlackbox.HTTPServer.Async.dll + True + + + ..\packages\SecureBlackbox.15.1.300\lib\net451\SecureBlackbox.LDAP.dll + True + + + ..\packages\SecureBlackbox.15.1.300\lib\net451\SecureBlackbox.LDAP.Async.dll + True + + + ..\packages\SecureBlackbox.15.1.300\lib\net451\SecureBlackbox.Mail.dll + True + + + ..\packages\SecureBlackbox.15.1.300\lib\net451\SecureBlackbox.Mail.Async.dll + True + + + ..\packages\SecureBlackbox.15.1.300\lib\net451\SecureBlackbox.MIME.dll + True + + + ..\packages\SecureBlackbox.15.1.300\lib\net451\SecureBlackbox.MIME.Async.dll + True + + + ..\packages\SecureBlackbox.15.1.300\lib\net451\SecureBlackbox.Office.dll + True + + + ..\packages\SecureBlackbox.15.1.300\lib\net451\SecureBlackbox.Office.Async.dll + True + + + ..\packages\SecureBlackbox.15.1.300\lib\net451\SecureBlackbox.PDF.dll + True + + + ..\packages\SecureBlackbox.15.1.300\lib\net451\SecureBlackbox.PDF.Async.dll + True + + + ..\packages\SecureBlackbox.15.1.300\lib\net451\SecureBlackbox.PGP.dll + True + + + ..\packages\SecureBlackbox.15.1.300\lib\net451\SecureBlackbox.PGP.Async.dll + True + + + ..\packages\SecureBlackbox.15.1.300\lib\net451\SecureBlackbox.PGPLDAP.dll + True + + + ..\packages\SecureBlackbox.15.1.300\lib\net451\SecureBlackbox.PGPLDAP.Async.dll + True + + + ..\packages\SecureBlackbox.15.1.300\lib\net451\SecureBlackbox.PGPMIME.dll + True + + + ..\packages\SecureBlackbox.15.1.300\lib\net451\SecureBlackbox.PGPMIME.Async.dll + True + + + ..\packages\SecureBlackbox.15.1.300\lib\net451\SecureBlackbox.PGPSSH.dll + True + + + ..\packages\SecureBlackbox.15.1.300\lib\net451\SecureBlackbox.PGPSSH.Async.dll + True + + + ..\packages\SecureBlackbox.15.1.300\lib\net451\SecureBlackbox.PGPTLS.dll + True + + + ..\packages\SecureBlackbox.15.1.300\lib\net451\SecureBlackbox.PGPTLS.Async.dll + True + + + ..\packages\SecureBlackbox.15.1.300\lib\net451\SecureBlackbox.PKI.dll + True + + + ..\packages\SecureBlackbox.15.1.300\lib\net451\SecureBlackbox.PKI.Async.dll + True + + + ..\packages\SecureBlackbox.15.1.300\lib\net451\SecureBlackbox.PKIPDF.dll + True + + + ..\packages\SecureBlackbox.15.1.300\lib\net451\SecureBlackbox.PKIPDF.Async.dll + True + + + ..\packages\SecureBlackbox.15.1.300\lib\net451\SecureBlackbox.PKISMIME.dll + True + + + ..\packages\SecureBlackbox.15.1.300\lib\net451\SecureBlackbox.PKISSH.dll + True + + + ..\packages\SecureBlackbox.15.1.300\lib\net451\SecureBlackbox.PKISSH.Async.dll + True + + + ..\packages\SecureBlackbox.15.1.300\lib\net451\SecureBlackbox.SAMLCommon.dll + True + + + ..\packages\SecureBlackbox.15.1.300\lib\net451\SecureBlackbox.SAMLCommon.Async.dll + True + + + ..\packages\SecureBlackbox.15.1.300\lib\net451\SecureBlackbox.SAMLIDP.dll + True + + + ..\packages\SecureBlackbox.15.1.300\lib\net451\SecureBlackbox.SAMLIDP.Async.dll + True + + + ..\packages\SecureBlackbox.15.1.300\lib\net451\SecureBlackbox.SAMLSP.dll + True + + + ..\packages\SecureBlackbox.15.1.300\lib\net451\SecureBlackbox.SAMLSP.Async.dll + True + + + ..\packages\SecureBlackbox.15.1.300\lib\net451\SecureBlackbox.SFTP.dll + True + + + ..\packages\SecureBlackbox.15.1.300\lib\net451\SecureBlackbox.SFTP.Async.dll + True + + + ..\packages\SecureBlackbox.15.1.300\lib\net451\SecureBlackbox.SFTPCommon.dll + True + + + ..\packages\SecureBlackbox.15.1.300\lib\net451\SecureBlackbox.SFTPCommon.Async.dll + True + + + ..\packages\SecureBlackbox.15.1.300\lib\net451\SecureBlackbox.SFTPServer.dll + True + + + ..\packages\SecureBlackbox.15.1.300\lib\net451\SecureBlackbox.SFTPServer.Async.dll + True + + + ..\packages\SecureBlackbox.15.1.300\lib\net451\SecureBlackbox.SMIME.dll + True + + + ..\packages\SecureBlackbox.15.1.300\lib\net451\SecureBlackbox.SMIME.Async.dll + True + + + ..\packages\SecureBlackbox.15.1.300\lib\net451\SecureBlackbox.SOAPClient.dll + True + + + ..\packages\SecureBlackbox.15.1.300\lib\net451\SecureBlackbox.SOAPClient.Async.dll + True + + + ..\packages\SecureBlackbox.15.1.300\lib\net451\SecureBlackbox.SolFS.dll + True + + + ..\packages\SecureBlackbox.15.1.300\lib\net451\SecureBlackbox.SSHClient.dll + True + + + ..\packages\SecureBlackbox.15.1.300\lib\net451\SecureBlackbox.SSHClient.Async.dll + True + + + ..\packages\SecureBlackbox.15.1.300\lib\net451\SecureBlackbox.SSHCommon.dll + True + + + ..\packages\SecureBlackbox.15.1.300\lib\net451\SecureBlackbox.SSHCommon.Async.dll + True + + + ..\packages\SecureBlackbox.15.1.300\lib\net451\SecureBlackbox.SSHServer.dll + True + + + ..\packages\SecureBlackbox.15.1.300\lib\net451\SecureBlackbox.SSHServer.Async.dll + True + + + ..\packages\SecureBlackbox.15.1.300\lib\net451\SecureBlackbox.SSLClient.dll + True + + + ..\packages\SecureBlackbox.15.1.300\lib\net451\SecureBlackbox.SSLClient.Async.dll + True + + + ..\packages\SecureBlackbox.15.1.300\lib\net451\SecureBlackbox.SSLCommon.dll + True + + + ..\packages\SecureBlackbox.15.1.300\lib\net451\SecureBlackbox.SSLCommon.Async.dll + True + + + ..\packages\SecureBlackbox.15.1.300\lib\net451\SecureBlackbox.SSLServer.dll + True + + + ..\packages\SecureBlackbox.15.1.300\lib\net451\SecureBlackbox.SSLServer.Async.dll + True + + + ..\packages\SecureBlackbox.15.1.300\lib\net451\SecureBlackbox.XML.dll + True + + + ..\packages\SecureBlackbox.15.1.300\lib\net451\SecureBlackbox.XML.Async.dll + True + + + ..\packages\SecureBlackbox.15.1.300\lib\net451\SecureBlackbox.XMLSecurity.dll + True + + + ..\packages\SecureBlackbox.15.1.300\lib\net451\SecureBlackbox.XMLSecurity.Async.dll + True + + + ..\packages\SecureBlackbox.15.1.300\lib\net451\SecureBlackbox.ZIP.dll + True + + + ..\packages\SecureBlackbox.15.1.300\lib\net451\SecureBlackbox.ZIP.Async.dll + True + diff --git a/Project-Unite/packages.config b/Project-Unite/packages.config index 7863c46..321930e 100644 --- a/Project-Unite/packages.config +++ b/Project-Unite/packages.config @@ -43,8 +43,10 @@ + +