Finished up the SMTP side of #429

This commit is contained in:
tidusjar 2016-07-25 10:11:33 +01:00
commit 0e99dc29c9
2 changed files with 42 additions and 39 deletions

View file

@ -176,13 +176,16 @@ namespace PlexRequests.Services.Notification
{ {
using (var client = new SmtpClient()) using (var client = new SmtpClient())
{ {
client.Connect(settings.EmailHost, settings.EmailPort, SecureSocketOptions.Auto); // Let MailKit figure out the correct SecureSocketOptions. client.Connect(settings.EmailHost, settings.EmailPort); // Let MailKit figure out the correct SecureSocketOptions.
// Note: since we don't have an OAuth2 token, disable // Note: since we don't have an OAuth2 token, disable
// the XOAUTH2 authentication mechanism. // the XOAUTH2 authentication mechanism.
client.AuthenticationMechanisms.Remove("XOAUTH2"); client.AuthenticationMechanisms.Remove("XOAUTH2");
client.Authenticate(settings.EmailUsername, settings.EmailPassword); if (settings.Authentication)
{
client.Authenticate(settings.EmailUsername, settings.EmailPassword);
}
await client.SendAsync(message); await client.SendAsync(message);
await client.DisconnectAsync(true); await client.DisconnectAsync(true);