Relay access denied 5.7.1

asp.net, asp.net-mvc, c#, credentials, sendmail

Solution

Since your smtp host port is 587, I think you should set smtpClient.EnableSsl to true before calling its Send method.

Problem

I've got the error "Relay access denied", but I can connect my account with some email programs. My code: ``` SmtpClient smtpClient = new SmtpClient(); NetworkCredential basicCredential = new NetworkCredential("xx@xx.com", "xxx"); MailMessage message = new MailMessage(); MailAddress fromAddress = new MailAddress("xx@xx.com"); smtpClient.Host = "mail.xx.com"; smtpClient.Port = 587; smtpClient.UseDefaultCredentials = false; smtpClient.Credentials = basicCredential; message.From = fromAddress; message.Subject = subject; message.IsBodyHtml = true; message.Body = body; message.To.Add("aa@aa.com"); try { smtpClient.Send(message); } catch (Exception ex) { //Relay access denied... } ``` Does anyone know the reason for this?

Original source