-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();
}
When I put the
EnableSsl
it appears the message the server does not support for secure connections.– Guilherme Alves