From 5a32e587482dd20b5daa1555a4d7609670d5a1f9 Mon Sep 17 00:00:00 2001 From: John Cardinal Date: Fri, 13 Jul 2018 16:58:46 +0000 Subject: [PATCH] Changes to work with new mail server --- rockfishCore.csproj | 2 +- util/RfMail.cs | 36 +++++++++++++++++++++++++----------- 2 files changed, 26 insertions(+), 12 deletions(-) diff --git a/rockfishCore.csproj b/rockfishCore.csproj index 336e6b0..731256a 100644 --- a/rockfishCore.csproj +++ b/rockfishCore.csproj @@ -12,7 +12,7 @@ - + \ No newline at end of file diff --git a/util/RfMail.cs b/util/RfMail.cs index d706c8e..e1a1bb5 100644 --- a/util/RfMail.cs +++ b/util/RfMail.cs @@ -16,10 +16,12 @@ namespace rockfishCore.Util public static class RfMail { - public const string MAIL_SMPT_ADDRESS = "smtp.ayanova.com"; + public const string MAIL_SMPT_ADDRESS = "mail.ayanova.com"; public const int MAIL_SMPT_PORT = 465; public const string MAIL_IMAP_ADDRESS = "mail.ayanova.com"; - public const int MAIL_IMAP_PORT = 993; + //public const int MAIL_IMAP_PORT = 993; + //testing + public const int MAIL_IMAP_PORT = 143; public const string MAIL_ACCOUNT_SUPPORT = "support@ayanova.com"; public const string MAIL_ACCOUNT_PASSWORD_SUPPORT = "e527b6c5a00c27bb61ca694b3de0ee178cbe3f1541a772774762ed48e9caf5ce"; @@ -70,7 +72,7 @@ namespace rockfishCore.Util //Accept all SSL certificates (in case the server supports STARTTLS) //(we have a funky cert on the mail server) client.ServerCertificateValidationCallback = (s, c, h, e) => true; - client.Connect(MAIL_SMPT_ADDRESS, MAIL_SMPT_PORT, true); + client.Connect(MAIL_SMPT_ADDRESS, MAIL_SMPT_PORT); // Note: since we don't have an OAuth2 token, disable // the XOAUTH2 authentication mechanism. @@ -90,7 +92,7 @@ namespace rockfishCore.Util //Accept all SSL certificates (in case the server supports STARTTLS) //(we have a funky cert on the mail server) client.ServerCertificateValidationCallback = (s, c, h, e) => true; - client.Connect(MAIL_SMPT_ADDRESS, MAIL_SMPT_PORT, true); + client.Connect(MAIL_SMPT_ADDRESS, MAIL_SMPT_PORT); // Note: since we don't have an OAuth2 token, disable // the XOAUTH2 authentication mechanism. @@ -282,7 +284,7 @@ namespace rockfishCore.Util { // Accept all SSL certificates client.ServerCertificateValidationCallback = (s, c, h, e) => true; - client.Connect(MAIL_IMAP_ADDRESS, MAIL_IMAP_PORT, true); + client.Connect(MAIL_IMAP_ADDRESS, MAIL_IMAP_PORT); // Note: since we don't have an OAuth2 token, disable // the XOAUTH2 authentication mechanism. client.AuthenticationMechanisms.Remove("XOAUTH2"); @@ -313,7 +315,7 @@ namespace rockfishCore.Util { // Accept all SSL certificates client.ServerCertificateValidationCallback = (s, c, h, e) => true; - client.Connect(MAIL_IMAP_ADDRESS, MAIL_IMAP_PORT, true); + client.Connect(MAIL_IMAP_ADDRESS, MAIL_IMAP_PORT); // Note: since we don't have an OAuth2 token, disable // the XOAUTH2 authentication mechanism. client.AuthenticationMechanisms.Remove("XOAUTH2"); @@ -338,7 +340,7 @@ namespace rockfishCore.Util { // Accept all SSL certificates client.ServerCertificateValidationCallback = (s, c, h, e) => true; - client.Connect(MAIL_IMAP_ADDRESS, MAIL_IMAP_PORT, true); + client.Connect(MAIL_IMAP_ADDRESS, MAIL_IMAP_PORT); // Note: since we don't have an OAuth2 token, disable // the XOAUTH2 authentication mechanism. client.AuthenticationMechanisms.Remove("XOAUTH2"); @@ -408,7 +410,7 @@ namespace rockfishCore.Util { // Accept all SSL certificates client.ServerCertificateValidationCallback = (s, c, h, e) => true; - client.Connect(MAIL_IMAP_ADDRESS, MAIL_IMAP_PORT, true); + client.Connect(MAIL_IMAP_ADDRESS, MAIL_IMAP_PORT); // Note: since we don't have an OAuth2 token, disable // the XOAUTH2 authentication mechanism. client.AuthenticationMechanisms.Remove("XOAUTH2"); @@ -450,22 +452,33 @@ namespace rockfishCore.Util private static List getInboxSummariesFor(string sourceAccount, string sourcePassword) { + Console.WriteLine($"getInboxSummariesFor {sourceAccount}"); List ret = new List(); using (var client = new ImapClient()) { // Accept all SSL certificates client.ServerCertificateValidationCallback = (s, c, h, e) => true; - client.Connect(MAIL_IMAP_ADDRESS, MAIL_IMAP_PORT, true); + + //client.Connect(MAIL_IMAP_ADDRESS, MAIL_IMAP_PORT, true); + //testing + + Console.WriteLine($"connecting to {MAIL_IMAP_ADDRESS} on {MAIL_IMAP_PORT}"); + client.Connect(MAIL_IMAP_ADDRESS, MAIL_IMAP_PORT); + // Note: since we don't have an OAuth2 token, disable // the XOAUTH2 authentication mechanism. + Console.WriteLine($"removing XOAUTH2"); client.AuthenticationMechanisms.Remove("XOAUTH2"); + Console.WriteLine($"authenticating..."); client.Authenticate(sourceAccount, sourcePassword); var inbox = client.Inbox; + Console.WriteLine($"opening inbox..."); inbox.Open(FolderAccess.ReadOnly); - + Console.WriteLine($"fetching summaries..."); var summaries = inbox.Fetch(0, -1, MessageSummaryItems.Full | MessageSummaryItems.UniqueId); + Console.WriteLine($"disconnecting..."); client.Disconnect(true); foreach (var summary in summaries) { @@ -509,7 +522,8 @@ namespace rockfishCore.Util { // Accept all SSL certificates client.ServerCertificateValidationCallback = (s, c, h, e) => true; - client.Connect(MAIL_IMAP_ADDRESS, MAIL_IMAP_PORT, true); + //client.Connect(MAIL_IMAP_ADDRESS, MAIL_IMAP_PORT, true); + client.Connect(MAIL_IMAP_ADDRESS, MAIL_IMAP_PORT); // Note: since we don't have an OAuth2 token, disable // the XOAUTH2 authentication mechanism. client.AuthenticationMechanisms.Remove("XOAUTH2");