SMTP connection error with C # (authenticated)

1

Below is the Script used when trying to send an error: SSPI call failed. the Client and Server can not communicate because they do not have a common algorithm.

string CorpoEmail = file;
    MailMessage mailMessage = new MailMessage();
    // Endereco que irá aparecer no e-mail do usuário
    mailMessage.From = new MailAddress("[email protected]", "Fale Conosco");
    // Destinatarios do e-mail, para incluir mais de um basta separar por ponto e virgula
    mailMessage.To.Add(destinatario);
    mailMessage.Subject = assunto;
    mailMessage.IsBodyHtml = true;
    // Conteudo do corpo do e-mail
    mailMessage.Body = CorpoEmail.ToString();
    mailMessage.Priority = MailPriority.High;
    //smtp do e-mail que irá enviar
    SmtpClient smtpClient = new SmtpClient();
    smtpClient.EnableSsl = true;
    smtpClient.Host = "smtp.host.com.br";
    smtpClient.Port = 587;


    smtpClient.UseDefaultCredentials = false;
    //credenciais da conta que utilizará para enviar o e-mail
    smtpClient.Credentials = new 
    NetworkCredential("[email protected]", "senha");
    smtpClient.Send(mailMessage);
    return true;
    
asked by anonymous 06.05.2017 / 14:08

1 answer

2

Apparently you are trying to make an SSL / TLS call using a non-secure (587) port, try to disable the SSL / TLS function by replacing this value:

smtpClient.EnableSsl = true;

By this:

smtpClient.EnableSsl = false;

This should solve your problem, if the error persists, make sure the host is correct and active in "smtpClient.Host".

    
22.06.2017 / 10:45