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("[email protected]", "xxx");
MailMessage message = new MailMessage();
MailAddress fromAddress = new MailAddress("[email protected]");
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("[email protected]");
try
{
smtpClient.Send(message);
}
catch (Exception ex)
{
//Relay access denied...
}
Does anyone know the reason for this?
Since your smtp host port is 587, I think you should set smtpClient.EnableSsl to true before calling its Send method.