Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/320.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/asp.net/34.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 不要通过主机发送电子邮件_C#_Asp.net_Email - Fatal编程技术网

C# 不要通过主机发送电子邮件

C# 不要通过主机发送电子邮件,c#,asp.net,email,C#,Asp.net,Email,我使用下面的代码发送电子邮件,但每次都会出现此错误 发送邮件失败 我的代码: MailMessage message = new MailMessage("donot-reply@mydomain.ir", "reception@yahoo.com", "test", "msg"); message.IsBodyHtml = true; SmtpClient emailClient = new SmtpClient("mail.mydomain.ir",110); emailClient.Cre

我使用下面的代码发送电子邮件,但每次都会出现此错误

发送邮件失败

我的代码:

MailMessage message = new MailMessage("donot-reply@mydomain.ir", "reception@yahoo.com", "test", "msg");
message.IsBodyHtml = true;
SmtpClient emailClient = new SmtpClient("mail.mydomain.ir",110);
emailClient.Credentials = new System.Net.NetworkCredential("donot-reply@mydomain.ir", "donot-replyA!1");
emailClient.EnableSsl = true;
emailClient.Send(message);

我可以在thunder birds中通过此电子邮件地址发送电子邮件,但我不知道为什么我不能在.NET中发送电子邮件。快速浏览一下,如果您使用的简单邮件传输协议端口无效,请尝试以下操作:

港口:25 港口:587
如果没有堆栈跟踪或有关错误的更多信息,我们将不会有多大用处。

您是否查看了堆栈跟踪?必须有更详细的例外情况,您得到的MTP服务器通常会作出响应,而不仅仅是发送邮件失败。服务器响应的详细信息是什么?具体在哪里失败了?完全有可能代码没有问题,SMTP服务器只是拒绝传递邮件。@David我如何获得服务器响应?@job1393:如果.Send引发异常,则该异常中可能会有详细信息。我将端口更改为587,一切正常。但当我运行程序并调试它,然后按f11时,它可以发送邮件,但当删除断点并运行它时,它不会发送。为什么?