gpt4 book ai didi

c# - 使用 SmtpClient 发送电子邮件时的故障排除 "Mailbox unavailable. The server response was: Access denied - Invalid HELO name"

转载 作者:可可西里 更新时间:2023-11-01 09:06:50 24 4
gpt4 key购买 nike

我一直在尝试通过 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: Mailbox unavailable. The server response was: Access denied - Invalid HELO name (See RFC2821 4.1.1.1)

那么,我现在该怎么办? SmtpClient 是否应该是特殊的并且只能在特定的 SMTP 服务器上工作?

最佳答案

似乎您的用户名/密码对没有通过您的 SMTP 服务器进行身份验证

编辑

我想,我发现这里出了什么问题。我已经在下面更正了您的版本。

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);

关于c# - 使用 SmtpClient 发送电子邮件时的故障排除 "Mailbox unavailable. The server response was: Access denied - Invalid HELO name",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3155242/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com