Server does not support secure connections

I get an error "Server does not support secure connections" with my code below.

SmtpClient client = new SmtpClient(exchangeServer); client.UseDefaultCredentials = false; client.EnableSsl = true; client.Credentials = new NetworkCredential(user, password); MailAddress from = new MailAddress(fromAddress); MailAddress to = new MailAddress(to); MailMessage mail = new MailMessage(from, to); // ... client.Send(mail); 

How can I fix this problem?

+4
source share
3 answers

Your server does not support SSL on the default port; Most will not.

When you disable SSL, you will receive the message: “A secure connection is required for the SMTP server or the client failed authentication. Server response: 5.7.1 The client was not authenticated”

This tells you that you are not authenticated. Also, you said in a comment: "Because if I set UseDefaultCredentials = true and used my own user address in the" from "address, I can send the email successfully."

This is apparently a problem with setting up the SMTP server. You will need to obtain the appropriate credentials or install an SMTP server to allow sending mail from the web server.

+3
source

Which port are you using? You may find that you need to specify a port in your SmtpClient object.

0
source

records

 client.EnableSsl = false; 
-3
source

Source: https://habr.com/ru/post/1385069/


All Articles