SendEmail in ASP.net shows me Syntax error, command unrecognized. The server response was: Dovecot ready

匿名 (未验证) 提交于 2019-12-03 02:23:02

问题:

I want to send mail using ASP.NET with this code:

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

But after executing i got this error :

 Syntax error, command unrecognized. The server response was: Dovecot ready. 

This is the stacktrace

[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 

回答1:

There might be issue with SMTP Server.

Try with GMAIL Settings, if mail is working with GMAIL server, then most probably there is issue with your Mailing Server. It looks like you are using POP3 or IMAP server not SMTP Server, please check configuration of your Server

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


标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!