I 'm working on an mvc application to fetch emails from my gmail account using MailKit, on my local computer it works perfectly. However, when uploading it on the host i get the "A socket operation was attempted to an unreachable network". I don't have ssl enabled on the host. all suggestions are appreciated I have crawled the web and tried all the solutions even S22.Imap.dll but still same error.
using (var client = new ImapClient())
{
using (var cancel = new CancellationTokenSource())
{
// For demo-purposes, accept all SSL certificates
client.ServerCertificateValidationCallback = (s, c, h, e) => true;
var ips = Dns.GetHostAddresses("imap.gmail.com");
try
{
client.Connect("imap.gmail.com", 993, true, cancel.Token);
}
catch
{
foreach (var ip in ips)
{
try
{
client.Connect(ip.ToString(), 993, true, cancel.Token);
}
catch (SocketException e) //error means server is down, try other IP
{
//nothing, check next IP for connection
}
}
}
// Note: since we don't have an OAuth2 token, disable
// the XOAUTH2 authentication mechanism.
client.AuthenticationMechanisms.Remove("XOAUTH2");
client.Authenticate(username, password);}}
Is this SSL Problem ? appreciate all the help I can get
Regards,