using InABox.Core; using InABox.Mail; using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace InABox.API { public class ExchangeProvider : ISMSProvider { private ExchangeMailer Mailer; public ExchangeProvider(string host, int port, string username, string password) { Mailer = new ExchangeMailer() { MailboxHost = host, MailboxPort = port, MailboxUserName = username, MailboxPassword = password }; } public SMSProviderType ProviderType => SMSProviderType.Exchange; public TwoFactorAuthenticationType TwoFactorAuthenticationType => TwoFactorAuthenticationType.Email; public bool SendMessage(string recipient, string message) { if (Mailer.Connect()) { var imapMessage = Mailer.CreateMessage(); imapMessage.Subject = "Message from PRS"; imapMessage.Body = message; imapMessage.IsHTML = false; imapMessage.To = new List { recipient }; Mailer.SendMessage(imapMessage); return true; } return false; } } }