when sending email
From Visual sutudio Works fine, and from local machine IIs Works fine too
But in the VPS Windows server server IIS, Gives this error
SmtpProtocolException: The SMTP server has unexpectedly disconnected.
I am using MailKit for sending emails
using MailKit.Net.Smtp;
using MimeKit;
This is my Code
var email = Client.email; var emailMessage = new MimeMessage(); emailMessage.From.Add(new MailboxAddress("My Name", "myemail@live.com.mx")); emailMessage.To.Add(new MailboxAddress("somebody@mail.com", email)); emailMessage.Subject = "Hello from Compucaribe"; var builder = new BodyBuilder(); builder.TextBody = @"Hello this is a test email"; builder.Attachments.Add(Path + @"\directory\" + "file" + ".xml"); builder.Attachments.Add(Path + @"\directory\" + "file" + ".pdf"); emailMessage.Body = builder.ToMessageBody(); using (var client = new SmtpClient()) { client.Connect("smtp.live.com", 587, false); client.AuthenticationMechanisms.Remove("XOAUTH2"); client.Authenticate("myemail@live.com.mx", "mypassword"); client.Send(emailMessage); client.Disconnect(true); }