发送电子邮件时出错

发布于 2024-11-29 20:06:06 字数 595 浏览 1 评论 0原文

我在以下位置创建了一个简单的应用程序: graficaromana.com.br

在联系表单中 (http://graficaromana.com.br/Contato) 当我尝试发送电子邮件时出现错误。 本地邮件发送正常,没有任何错误。

我需要在主机上进行一些设置吗?在域中?

错误:

System.Net.Sockets.SocketException 连接尝试失败,因为 关联方在一段时间后没有做出适当的回应, 或建立的连接失败,因为连接的主机未能 回复209.85.225.108:25

请参阅链接中的代码以了解更多详细信息: https://gist.github.com/1149028< /a>

I created a simple application at: graficaromana.com.br

In the contact form (http://graficaromana.com.br/Contato) when I try to send an email I get an error.
Locally the mail is sent normally without any error.

Is there some setting I have to do on the host? in the domain?

Error:

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 209.85.225.108:25

See the code for more details in link: https://gist.github.com/1149028

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

南笙 2024-12-06 20:06:06

看起来远程主机可能有一个单独的服务器,用于发送邮件,或者您必须被列入主机白名单才能发送邮件,并且可能需要用户名和密码。没有看过你的代码,但当涉及防火墙并且尝试发送的机器无法通过防火墙访问时,我看到它们出现某种错误,因为防火墙根本不响应,你会得到类似“服务器做了”的答案没有及时响应”或“服务器在一定时间后没有响应”我假设您在此处发帖之前已询问托管提供商有关发送邮件的信息,以及应如何发送邮件的偏好进行?正确的?

如果是这样,请提供有关他们所说内容的信息,

这是发送电子邮件的代码示例:

var smtpClient = new SmtpClient();
var message = new MailMessage();
smtpClient.port = 25;
message.from = "[email protected]";
message.To.Add("[email protected],[email protected]";
message.Subject = "Contact from website";
message.IsBodyHtml = true;
message.Body = "<html><head></head><body>TEST</body></html>"

try { 
   smtpClient.Host = "relay.server.you.have.from.host";
   smtpClient.Send(message);
} catch( Exception ) {
   // host is down or we are local try other servers
   // here you can have more try / catch
   smtpClient.Host = "127.0.0.1"
   smtpClient.Send(message);
}

looks like the remote host has maybe a separate server they use for sending mail out or that you have to be whitelisted with the host in order to send mail and a username and password may be required. have not looked at your code but i see them kind of errors when there is a firewall involved and the machine trying to send does not have access through the firewall, as the firewall does not respond at all you get an answer like ' The server did not respond in a timely manner' or 'the server did not respond after a certain amount of time' i am assuming that before you posted on here that you have asked the hosting provider about sending mail, and what there preference is on how this should be carried out? right?

if so please provide info on what they have said

here is a sample of code to send email:

var smtpClient = new SmtpClient();
var message = new MailMessage();
smtpClient.port = 25;
message.from = "[email protected]";
message.To.Add("[email protected],[email protected]";
message.Subject = "Contact from website";
message.IsBodyHtml = true;
message.Body = "<html><head></head><body>TEST</body></html>"

try { 
   smtpClient.Host = "relay.server.you.have.from.host";
   smtpClient.Send(message);
} catch( Exception ) {
   // host is down or we are local try other servers
   // here you can have more try / catch
   smtpClient.Host = "127.0.0.1"
   smtpClient.Send(message);
}
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文