0

What could be the solution for this error.

System.Net.Mail.SmtpException: 'The SMTP server requires a secure connection or The server response was: #5.7.0 Must issue a STARTTLS command first'

using (var smtpclient = new CvxSmtpClient("username", "password", 587))

                        message.Body = email.message;
                        smtpclient.EnableSsl = false;
                        smtpclient.Send(message);                           
                        var param = new SqlParameter();
                        param.ParameterName = "@id";
                        param.Value = email.id;
                        db.ExecuteSql(queryUpdateEmailsToSend, param);
Joundill
  • 6,828
  • 12
  • 36
  • 50

1 Answers1

0

The SMTP server refuses insecure connections.

You set smtpclient.EnableSsl = false, so the SmtpClient doesn't use SSL. Try setting it to true.

For more details have a look at the docs: SmtpClient.EnableSsl Property

Michael Schnerring
  • 3,584
  • 4
  • 23
  • 53
  • Even after setting smtpclient.EnableSsl = true. I'm getting this error "system" at system.net.mail.mailcommand.checkResponse(SmtpStatusCode StatusCode, String response)\r\n at system.net.mail.mailcommand.Send(SmtpConnection conn, – Reshimma Pasupathi Sep 17 '20 at 15:07
  • @ReshimmaPasupathi add the new error to your question since it doesn't seem to fit a comment and fix the issues with your initial question while you're on it. Also, please format your content properly. Read [Markdown help](https://stackoverflow.com/editing-help). – Michael Schnerring Sep 17 '20 at 15:21