在asp.net中发送电子邮件时无法连接到远程服务器 [英] Unable to connect to remote server while sending email in asp.net

查看:386
本文介绍了在asp.net中发送电子邮件时无法连接到远程服务器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好



使用电子邮件发送代码时出现上述错误我的代码是

Hi all

The above error arising while using email sending code my code is

string fromAddress = "mymail";
string fromPassword = "mypassword";
  
try
{
    var smtp = new System.Net.Mail.SmtpClient();
    {
        smtp.Host = "smtp.gmail.com";
        smtp.Port = 587;
        smtp.EnableSsl = true;
        smtp.DeliveryMethod = System.Net.Mail.SmtpDeliveryMethod.Network;
        smtp.Credentials = new NetworkCredential(fromAddress, fromPassword);
        smtp.Timeout = 20000;
    }
    // Passing values to smtp object
    smtp.Send(fromAddress, toAddress, MailSubject, Body);
}



我google了很多次但没有得到适当的解决方案。端口587是无效的,防火墙阻塞也不存在。


I googled many times but didnt get proper solution. Port 587 is enbled and firewall blocking also not there.

推荐答案

首先,确保连接到gmail服务器的凭据正确。



另一件事是你没有为 MailSubject Body 指定值,但调用了函数smtp.Send()



请查看通过Gmail发送.NET中的电子邮件 [ ^ ],我可以在那里找到一些差异。



尝试实现这些答案。

请让我知道,如果你仍然遇到问题,我会为你工作。



谢谢...
First of all, make sure that the credentials are correct to connect to the gmail server.

Another thing is you have not assigned values to "MailSubject" or "Body", but called the function "smtp.Send()".

Please have a look at the useful answers at Sending email in .NET through Gmail[^], where I am able to find some differences.

Try to implement those answers.
Please let me know, if you still face problems, I will work out for you then.

Thanks...


大家好

感谢您的回复。我得到了解决方案

如果您使用任何防病毒软件,请检查它的日志,看是否是因为防病毒软件。当McAffee阻止我的邮件时,我遇到了同样的问题(有一个安全政策 - 防止群发邮件蠕虫发送邮件)。编辑此策略并将您的应用程序添加到例外列表中。在我的情况下,这排序问题。请检查它是否适合您。
hi all
Thanks for the response.I got solution as
if you are using any antivirus software check it''s log to see whether it is because of the antivirus. I faced same problem when McAffee was blocking my mails (there is a security policy - Prevent mass mailing worms from sending mails). Edit this policy and add your application to the exception list. In my case this sorted the problem. Please check if it works for you.


大家好。感谢您的回复。我得到的解决方案就好像您使用的是任何防病毒软件一样检查它的日志,看它是否是因为杀毒软件。当McAffee阻止我的邮件时,我遇到了同样的问题(有一个安全政策 - 防止群发邮件蠕虫发送邮件)。编辑此策略并将您的应用程序添加到例外列表中。在我的情况下,这排序问题。请检查它是否适合您。
hi all Thanks for the response.I got solution as if you are using any antivirus software check it''s log to see whether it is because of the antivirus. I faced same problem when McAffee was blocking my mails (there is a security policy - Prevent mass mailing worms from sending mails). Edit this policy and add your application to the exception list. In my case this sorted the problem. Please check if it works for you.


这篇关于在asp.net中发送电子邮件时无法连接到远程服务器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆