我在c#中发送带有指定域的邮件时出现以下错误。邮箱不可用。服务器的响应是:Access denied - Invalid HELO name(见RFC2821 4.1.1.1)
当我用gmail主机发送邮件时,它工作得很好。
Thanks in advance
一个可能的原因是您使用的发件人与电子邮件的发件人不同。请注意,所使用的网络凭证与邮件消息发送者相同。
见类似问题的原始答案
string to = "receiver@domain.com";
//It seems, your mail server demands to use the same email-id in SENDER as with which you're authenticating.
//string from = "sender@domain.com";
string from = "test@domain.com";
string subject = "Hello World!";
string body = "Hello Body!";
MailMessage message = new MailMessage(from, to, subject, body);
SmtpClient client = new SmtpClient("smtp.domain.com");
client.UseDefaultCredentials = false;
client.Credentials = new NetworkCredential("test@domain.com", "password");
client.Send(message);