在asp.net中发送电子邮件收到错误? [英] sending email in asp.net getting error?
本文介绍了在asp.net中发送电子邮件收到错误?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想从我的页面向不同的人发送电子邮件我正在使用web.config设置发送邮件如下:
I want to send email from my page to different persons i am using the web.config setting to send mail as follow:
<appsettings>
<add key="webmasteremail" value="someone@somedomain.com" />
</appSettings
>
和代码隐藏文件:
and in codebehind file :
SmtpClient client = new SmtpClient();
client.Send(ConfigurationManager.AppSettings["webmasteremail"], "irfan2009@namal.edu.pk", "hi", "mymail");</pre>
但我收到此错误
but i get this error
System.Net.Sockets.SocketException: No connection could be made because the target machine actively refused it 127.0.0.1:25
i不知道这个错误发生了以及如何解决它。请提前帮助我。
web.confi设置就好像
i dont know wht this error occur and how to resolve it . plz help me thnks in advance.
[edit]
web.confi setting is like
<add key="webmasteremail" value="someone@somedomain.com">
and
<system.net>
<mailsettings>
<smtp>
<network host="localhost" defaultcredentials="true">
</network></smtp>
</mailsettings>
</system.net></add>
[/ edit]
[/edit]
推荐答案
你几乎肯定也需要授权:现在几乎没有电子邮件系统被配置为允许匿名用户发送电子邮件。
看看这个:使用或不使用附件在C#中发送电子邮件:通用例程。 [ ^ ] - 我知道它有效,因为它是我使用的代码 - 而web.config看起来像这样:
You almost certainly need authorization as well: almost no email systems these days are configured to allow "anonymous users" to send emails.
Have a look at this: Sending an Email in C# with or without attachments: generic routine.[^] - I know it works, because it's the code I use - and the web.config looks like this:
<appSettings>
<add key="Development" value="True"/>
<add key="SMTPHost" value="smtp.REDACTED.com"/>
<add key="SMTPCredentialUser" value="MyEmail@REDACTED.com"/>
<add key="SMTPCredentialPassword" value="MyPassword"/>
<add key="SMTPDefaultFromAddress" value="Webmaster@REDACTED.com"/>
</appSettings>
你能不能请确保您输入了正确的凭据?本地主机?这是正确的吗?
Could you please make sure that you have entered correct credentials? Localhost? Is it correct?
这篇关于在asp.net中发送电子邮件收到错误?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文