Changes to work with new mail server
This commit is contained in:
@@ -12,7 +12,7 @@
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="2.1.0" />
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="2.1.0" />
|
||||
<PackageReference Include="jose-jwt" Version="2.4.0" />
|
||||
<PackageReference Include="mailkit" Version="2.0.4" />
|
||||
<PackageReference Include="mailkit" Version="2.0.5" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
@@ -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<rfMessageSummary> getInboxSummariesFor(string sourceAccount, string sourcePassword)
|
||||
{
|
||||
Console.WriteLine($"getInboxSummariesFor {sourceAccount}");
|
||||
List<rfMessageSummary> ret = new List<rfMessageSummary>();
|
||||
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");
|
||||
|
||||
Reference in New Issue
Block a user