Error sending email ASP.NET

Asked

Viewed 466 times

0

I am with a client and he is having problems sending email by the application in Asp. The code is as follows:

        string nomeRemetente = "Remetente";

        string emailRemetente = "[email protected]";
        string assuntoMensagem = assunto;
        MailMessage objEmail = new MailMessage();
        objEmail.From = new System.Net.Mail.MailAddress(nomeRemetente + "<" + emailRemetente + ">");


            objEmail.To.Add("[email protected]");


        objEmail.Priority = System.Net.Mail.MailPriority.Normal;
        objEmail.IsBodyHtml = true;
        objEmail.Subject = assuntoMensagem;
        objEmail.Body = conteudoMensagem;
        objEmail.SubjectEncoding = System.Text.Encoding.GetEncoding("UTF-8");
        objEmail.BodyEncoding = System.Text.Encoding.GetEncoding("UTF-8");
        System.Net.Mail.SmtpClient objSmtp = new System.Net.Mail.SmtpClient();

        objSmtp.Host = "smtp.meudominio";
        objSmtp.UseDefaultCredentials = false;
        objSmtp.Credentials = new System.Net.NetworkCredential(emailRemetente, "senha");
        objSmtp.Port = 587;

        try
        {
            objSmtp.Send(objEmail);
        }
        catch (Exception ex)
        {

        }
        finally
        {
            objEmail.Dispose();
        }

When sending the error appears: "Incorrect command sequence. The response of the server was: 5.0.3 : Client host Rejected: For sending messages it is necessary to use the tool. To know how to correct this error go to: http://wiki.locaweb.com/pt-br/Email_Locaweb_-_Envio_Autenticado /This mail server requires Authentication", in which this link does not work.

And when I set the function objSmtp.EnableSsl = true; error: "Remote certificate is invalid"

1 answer

0


Include before the SEND method

ServicePointManager.ServerCertificateValidationCallback =
                (sender, certificate, chain, sslPolicyErrors) => true;

This code passes through the validation of the safety certificate.

Safely use.

I hope it helps.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.