用asp.net发送电子邮件 [英] sending Email with asp.net
问题描述
我尝试从asp.net发送电子邮件我正在使用此代码
I tried to send Email from asp.net I am using this code
MailMessage msg = new MailMessage();
msg.From = new MailAddress("username@domain.com");
msg.To.Add(TextBox1.Text);
msg.Subject = TextBox2.Text;
msg.Body = TextBox3.Text;
SmtpClient sc = new SmtpClient("wmail.link.net", 25);
sc.Credentials = new NetworkCredential("username", "xxxxxx", "wmail.link.net");
sc.Send(msg);
LabelResult.Text = "Mail sent";
LabelResult.Font.Size = 30;
我收到此错误
System.Net.Mail.SmtpException:发送邮件失败。 ---> System.Net.WebException:无法解析远程名称:System.Net.ServicePoint.GetConnection上的'wmail.link.net'(PooledStream PooledStream,Object owner,Boolean async,IPAddress& address,Socket& abortSocket,Socket& abortSocket6 System.Net.ConnectionPool.GetConnection(Object)上的System.Net.PooledStream.Activate(Object owningObject,GeneralAsyncDelegate asyncCallback)处的System.Net.PooledStream.Activate(Object owningObject,Boolean async,Int32 timeout,GeneralAsyncDelegate asyncCallback)上的,Int32超时) System.Net.Mail.SmtpClient.Send上的System.Net.Mail.SmtpConnection.GetConnection(字符串主机,Int32端口)中的owningObject,GeneralAsyncDelegate asyncCallback,Int32 creationTimeout)(MailMessage消息)---内部异常堆栈跟踪结束 - - 在System.Net.Mail.SmtpClient.Send(MailMessage消息)at_Default.Button1_Click(Object sender,EventArgs e)
请帮助!
and I get this error
System.Net.Mail.SmtpException: Failure sending mail. ---> System.Net.WebException: The remote name could not be resolved: 'wmail.link.net' at System.Net.ServicePoint.GetConnection(PooledStream PooledStream, Object owner, Boolean async, IPAddress& address, Socket& abortSocket, Socket& abortSocket6, Int32 timeout) at System.Net.PooledStream.Activate(Object owningObject, Boolean async, Int32 timeout, GeneralAsyncDelegate asyncCallback) at System.Net.PooledStream.Activate(Object owningObject, GeneralAsyncDelegate asyncCallback) at System.Net.ConnectionPool.GetConnection(Object owningObject, GeneralAsyncDelegate asyncCallback, Int32 creationTimeout) at System.Net.Mail.SmtpConnection.GetConnection(String host, Int32 port) at System.Net.Mail.SmtpClient.Send(MailMessage message) --- End of inner exception stack trace --- at System.Net.Mail.SmtpClient.Send(MailMessage message) at _Default.Button1_Click(Object sender, EventArgs e)
any help please!
推荐答案
辩诉se使用本地电子邮件服务器进行测试: http://www.hmailserver.com/ [ ^ ]
它是免费的。
您的提供商将限制访问pop / smtp的次数,如果您尝试使用奇怪的命令拍摄SMTP / POP,也可能完全禁止您。
你的例外
Please use a local Email-Server for testing: http://www.hmailserver.com/[^]
It's free.
your provider will limit the number of accesses to the pop/smtp and might also ban you completely if you try to shoot the SMTP/POP with strange commands.
Your Exception
The remote name could not be resolved: 'wmail.link.net'
< br $>
表示该地址不存在或者至少无法解析为IP地址。
says that the address is not existing or at least can not be resolved to an IP address.
此错误消息相当不言自明:无法解析远程名称:'wmail.link.net'
您无法创建与SMTP服务器的连接已经指定。
您的代码没有任何问题。您只需要检查无法访问SMTP的原因('wmail.link.net'
)服务器
对于初学者,尝试从运行应用程序的计算机上ping wmail.link.net。
This error message is quite self-explanatory:The remote name could not be resolved: 'wmail.link.net'
You cannot create a connection to the SMTP server you have specified.
There is nothing wrong with your code. You just need to check why you can't access the SMTP ('wmail.link.net'
) server
For starters, try pinging wmail.link.net from the machine your application is running on.
如果你无法连接到任何smtp,你应该咨询你的网络部门,因为它似乎是您和提供商之间的防火墙的一般问题。您也可以尝试禁用本地Windows防火墙。
您也可以在 System.Net.Mail.SmtpException:发送邮件失败 [ ^ ]
If you cannot connect to any smtp you should consult your network department because it seems to be a general problem with a firewall between you and your provider. You can also try to disable your local windows firewall.
Also you can refer the same question in System.Net.Mail.SmtpException:Failure sending mail[^]
这篇关于用asp.net发送电子邮件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!