This commit is contained in:
@@ -9,6 +9,7 @@ using MailKit.Net.Imap;
|
||||
using MailKit.Search;
|
||||
using MailKit;
|
||||
using MimeKit;
|
||||
using MimeKit.Utils;
|
||||
|
||||
namespace rockfishCore.Util
|
||||
{
|
||||
@@ -108,6 +109,8 @@ namespace rockfishCore.Util
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
public static void SendMessage(string MessageFrom, string MessageTo, string MessageSubject, string MessageBody,
|
||||
bool trackDeliveryStatus = false, string CustomHeader = "", string CustomHeaderValue = "")
|
||||
{
|
||||
@@ -151,6 +154,51 @@ namespace rockfishCore.Util
|
||||
}//send message
|
||||
|
||||
|
||||
#region handle spam message
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Forward a message to the isspam@ayanova.com address and then erase it
|
||||
/// </summary>
|
||||
/// <param name="spamMessageId"></param>
|
||||
/// <param name="replyFromAccount"></param>
|
||||
public static void HandleSpamMessage(uint spamMessageId, rfMailAccount replyFromAccount)
|
||||
{
|
||||
using (var client = new ImapClient())
|
||||
{
|
||||
// Accept all SSL certificates
|
||||
client.ServerCertificateValidationCallback = (s, c, h, e) => 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");
|
||||
if (replyFromAccount == rfMailAccount.support)
|
||||
{
|
||||
client.Authenticate(MAIL_ACCOUNT_SUPPORT, MAIL_ACCOUNT_PASSWORD_SUPPORT);
|
||||
}
|
||||
else
|
||||
{
|
||||
client.Authenticate(MAIL_ACCOUNT_SALES, MAIL_ACCOUNT_PASSWORD_SALES);
|
||||
}
|
||||
|
||||
var spamFolder = client.GetFolder("Spam");
|
||||
|
||||
if (spamFolder != null){
|
||||
client.Inbox.Open(FolderAccess.ReadWrite);
|
||||
client.Inbox.MoveTo(new UniqueId(spamMessageId), spamFolder);
|
||||
}
|
||||
|
||||
|
||||
client.Disconnect(true);
|
||||
}
|
||||
}//spaminator
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
|
||||
|
||||
public static void ReplyMessage(uint replyToMessageId, rfMailAccount replyFromAccount, string replyBody,
|
||||
bool replyToAll, bool trackDeliveryStatus = false, string CustomHeader = "", string CustomHeaderValue = "")
|
||||
{
|
||||
@@ -522,7 +570,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, true);
|
||||
client.Connect(MAIL_IMAP_ADDRESS, MAIL_IMAP_PORT);
|
||||
// Note: since we don't have an OAuth2 token, disable
|
||||
// the XOAUTH2 authentication mechanism.
|
||||
|
||||
Reference in New Issue
Block a user