I have a problem sending email via Office 365 SMTP and MailKit. The exception I get is:
Unhandled Exception: System.IO.IOException: Unable to read data from the transport connection: An existing connection was forcibly closed by the remote host.
System.Net.Sockets.SocketException: An existing connection was forcibly closed by the remote host
https://github.com/jstedfast/MailKit
Code:
var smtpClient = new SmtpClient();
smtpClient.Connect("smtp.office365.com", 587, true);
Microsoft Office 365 settings should be correct:
The weird thing is that if I use the following everything works, even though Office 365 says SSL is required.
smtpClient.Connect("smtp.office365.com", 587, false);