我在c#中发送带有指定域名的邮件时有跟踪错误。 信箱不可用。服务器响应为:拒绝访问 - 无效的HELO名称(请参阅RFC2821 4.1.1.1)
当我使用gmail主机发送邮件时,它的工作正常。
提前致谢
答案 0 :(得分:0)
一个可能的原因是您使用的发件人与电子邮件的发件人不同。请注意,使用的网络凭据与邮件发件人相同。
在类似问题中查看此original answer。
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);