gpt4 book ai didi

asp.net - ASP.net 中的 SendEmail 显示语法错误,命令无法识别。服务器响应为 : Dovecot ready

转载 作者:行者123 更新时间:2023-12-03 19:27:20 26 4
gpt4 key购买 nike

我想使用带有以下代码的 ASP.NET 发送邮件:

 public void Semail(string subject, string messageBody, string toAddress)
{
MailMessage mail = new MailMessage();
mail.To.Add(toAddress);
//mail.To.Add("amit_jain_online@yahoo.com");
mail.From = new MailAddress("noreplykaramaoozi@eesharif.edu");
mail.Subject = subject;
string Body = messageBody;
mail.Body = Body;
mail.IsBodyHtml = true;
SmtpClient smtp = new SmtpClient();
smtp.Host = "sina.sharif.ir"; //Or Your SMTP Server Address

smtp.Credentials = new System.Net.NetworkCredential
("noreplykaramaoozi@eesharif.edu", "******");
//Or your Smtp Email ID and Password
smtp.EnableSsl = true;
smtp.Send(mail);
}

但是在执行后我得到了这个错误:
 Syntax error, command unrecognized. The server response was: Dovecot ready.

这是堆栈跟踪
[SmtpException: Syntax error, command unrecognized. The server response was: Dovecot ready.]
System.Net.Mail.SmtpConnection.GetConnection(ServicePoint servicePoint) +2176152
System.Net.Mail.SmtpClient.Send(MailMessage message) +2188821
Novitiate.fa.Register.btnLogin_Click(Object sender, EventArgs e) +2948
System.Web.UI.WebControls.Button.RaisePostBackEvent(String eventArgument) +154
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +3707

最佳答案

SMTP 服务器可能有问题。

尝试使用 GMAIL 设置,如果邮件正在使用 GMAIL 服务器,那么很可能是您的邮件服务器有问题。
看起来您使用的是 POP3 或 IMAP 服务器而不是 SMTP 服务器,请检查您的服务器配置

static void Main(string[] args)
{
var client = new SmtpClient("smtp.gmail.com", 587)
{
Credentials = new NetworkCredential("myusername@gmail.com", "mypwd"),
EnableSsl = true
};
client.Send("myusername@gmail.com", "myusername@gmail.com", "test", "testbody");
Console.WriteLine("Sent");
Console.ReadLine();
}

关于asp.net - ASP.net 中的 SendEmail 显示语法错误,命令无法识别。服务器响应为 : Dovecot ready,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23440952/

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