Transaction failed. The server response was: 5.7.1 <email>: Relay access denied

Asked

Viewed 2,015 times

-1

I have this code for sending emails and is returning the following error:

Transaction failed. Server response was: 5.7.1 : Relay access denied

Would anyone know tell me the problem? I’ve checked password, port, host and everything is ok.

        string nomeRemetente = "Contato";
        string emailRemetente = "email";
        string assuntoMensagem = assunto;
        MailMessage objEmail = new MailMessage();
        objEmail.From = new System.Net.Mail.MailAddress(nomeRemetente + "<" + emailRemetente + ">");
        foreach (var dest in destinatarios)
        {
            objEmail.To.Add(new MailAddress(dest));
        }
        objEmail.Bcc.Add(new MailAddress("emailbcc"));
        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.com.br";
        //objSmtp.UseDefaultCredentials = false;
        objSmtp.DeliveryMethod = SmtpDeliveryMethod.Network;
        objSmtp.Credentials = new System.Net.NetworkCredential(emailRemetente, "senha");
        objSmtp.Port = 587;

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

        }
        finally
        {
            objEmail.Dispose();
        }

1 answer

0

This error is usually related to authentication, if the data is correct it may be that the server requires the use of SSL, which can be activated by setting the property EnableSsl as true of SmtpClient

  • When I put the EnableSsl it appears the message the server does not support for secure connections.

Browser other questions tagged

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