【发布时间】:2010-07-01 05:13:31
【问题描述】:
我一直在尝试通过 C# 发送电子邮件。我在 Google 上搜索了各种示例,并从每个示例以及每个人最有可能使用的标准代码中提取了一些片段。
string to = "receiver@domain.com";
string from = "sender@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.Credentials = new NetworkCredential("test@domain.com", "password");
client.Send(message);
但是,我不断收到错误提示
System.Net.Mail.SmtpException:邮箱 不可用。服务器响应是: 访问被拒绝 - HELO 名称无效(请参阅 RFC2821 4.1.1.1)
那么,我现在该怎么办? SmtpClient 应该是特殊的并且只在特定的 SMTP 服务器上工作吗?
【问题讨论】:
-
看起来您尝试连接的任何服务器都需要您的客户端标识自己...
-
这是错字吗?
string to = receiver@domain.com;
标签: c# smtpclient