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 IMAPProvider : ISMSProvider { private IMAPMailer Mailer; public SMSProviderType ProviderType => SMSProviderType.IMAP; public TwoFactorAuthenticationType TwoFactorAuthenticationType => TwoFactorAuthenticationType.Email; public IMAPProvider(string host, int port, string username, string password) { Mailer = new IMAPMailer() { SMTPHost = host, SMTPPort = port, SMTPUserName = username, SMTPPassword = password }; } public bool SendMessage(string recipient, string message) { try { var imapMessage = Mailer.CreateMessage(); imapMessage.Subject = "Message from PRS"; imapMessage.Body = message; imapMessage.IsHTML = false; imapMessage.To = new List { recipient }; Mailer.SendMessage(imapMessage); } catch (Exception) { return false; } return true; } } }