Welcome to deBUG.to Community where you can ask questions and receive answers from Microsoft MVPs and other experts in our community.
0 like 0 dislike
3.3k views
in Programming by 66 69 85
edited by

In C# i got this error System.Net.Mail.SmtpException: 'Server does not support secure connections'When trying to send email in C# using SMTP.

Server does not support secure Connections

My mail sending code is simply this:

MailMessage message = new MailMessage();
SmtpClient smtp = new SmtpClient();

message.From = new MaillAddress("info@Domain");
message.To.Add("test@Domain");
message.IsBodyHtml = true;
message.Body = "<p>lorem</p>";

smtp.Port = 25;
smtp.Host = "smtp.outlook";
smtp.EnableSsl = True;
smtp.UseDefaultCredentials = false;
smtp.DeliveryMethod = SmtpDeliveryMethod.Network;
smtp.Send(message);

 


1 Answer

1 like 0 dislike
by 66 69 85
selected by
 
Best answer

Solving: Server does not support secure connections

To solve this issue, you can simply disable SSL by setting the smtp.EnableSsl to false as below:

smtp.EnableSsl = False;

The final code should be like below

MailMessage message = new MailMessage();
SmtpClient smtp = new SmtpClient();

message.From = new MaillAddress("info@Domain");
message.To.Add("test@Domain");
message.IsBodyHtml = true;
message.Body = "<p>lorem</p>";

smtp.Port = 25;
smtp.Host = "smtp.outlook";
smtp.EnableSsl = False;
smtp.UseDefaultCredentials = false;
smtp.DeliveryMethod = SmtpDeliveryMethod.Network;
smtp.Send(message);

See also:

  1. How to send email in C#
  2. The SMTP server requires a secure connection or the client was not authenticated. The server response was: 5.7.1 Client was not authenticated
If you don’t ask, the answer is always NO!
...