简体   繁体   English

通过asp.net发送电子邮件引发异常

[英]Send email via asp.net throw exception

I wrote this code in asp.net for sending email: 我在asp.net中编写了以下代码来发送电子邮件:

MailMessage mailObject = new MailMessage("a@b.com(I use fake email, exactly this email)", "info@mydomain.com", "contact us", "Test message");
SmtpClient smtpC = new SmtpClient("my smtp server name");
smtpC.Send(mailObject);

But I receive this exception: 但我收到此异常:

System.Net.Sockets.SocketException: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond System.Net.Sockets.SocketException:连接尝试失败,因为一段时间后连接方未正确响应,或者建立的连接失败,因为连接的主机未能响应

Also I can not connect to my "smpt server name" via tel net: 另外,我无法通过电话网连接到我的“ smpt服务器名称”:

telnet SMTPServerName 25 Connecting To SMTPServerName...Could not open connection to the host, on port 25: Connect failed telnet SMTPServerName 25正在连接到SMTPServerName ...无法打开与主机在端口25上的连接:连接失败

Is there any standard for troubleshooting this? 是否有解决此问题的标准?

Most likely the server name or port is incorrect. 服务器名称或端口很可能不正确。 Make sure you can send from an SMTP client before troubleshooting further in your code. 在进一步对代码进行故障排除之前,请确保可以从SMTP客户端发送邮件。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM