In our ASP.NET Core 1.1 app developed using Visual Studio 2017, we are using MailKiT to send email. But the following code is throwing the above error: using MailKit.Net.Smtp; using MimeKit; using System; namespace EmailApplication { class Program { static void Main(string[] args) { //Nps: mailer.its.nps.gov port: 25 //http://hintdesk.com/asp-net-web-api-identity-and-forgot-password/comment-page-1/ //http://www.binaryintellect.net/articles/df920caf-ba69-4714-938f-fbb358532c0f.aspx try { //From Address string FromAddress = "[email protected]"; string FromAdressTitle = "Email from ASP.NET Core 1.1"; //To Address string ToAddress = "[email protected]"; string ToAdressTitle = "Microsoft ASP.NET Core"; string Subject = "Hello World - Sending email using ASP.NET Core 1.1"; string BodyContent = "ASP.NET Core was previously called ASP.NET 5."; //Smtp Server string SmtpServer = "smtp.asciitex.com"; //Smtp Port Number int SmtpPortNumber = 587; var mimeMessage = new MimeMessage(); mimeMessage.From.Add(new MailboxAddress(FromAdressTitle, FromAddress)); mimeMessage.To.Add(new MailboxAddress(ToAdressTitle, ToAddress)); mimeMessage.Subject = Subject; mimeMessage.Body = new TextPart("plain") { Text = BodyContent }; using (var client = new SmtpClient()) { client.Connect(SmtpServer, SmtpPortNumber, false); // Note: only needed if the SMTP server requires authentication // Error 5.5.1 Authentication client.Authenticate(FromAddress, "myFromEmailPassword"); client.Send(mimeMessage); Console.WriteLine("The mail has been sent successfully !!"); Console.ReadLine(); client.Disconnect(true); } } catch (Exception ex) { throw ex; } } } }
It looks like you're trying to send via SSL/TLS somehow. If that's the case, the SMTP server host name you should use is "sm02.internetmailserver.net"