为什么 ASP.NET SmtpClient.Send() 使我的网站不可用?

发布于 2024-09-08 23:15:32 字数 753 浏览 1 评论 0原文

我有一个 ASP MVC 2 应用程序,我偶尔会通过它使用 SmtpClient.Send() 发送电子邮件。通常,电子邮件会分批发送,每批发送 1 到 50 封电子邮件,每批之间会间隔数小时甚至数天。我已经把这一切都设置好了,这样电子邮件实际上就可以正常发送了。但是,问题是,当电子邮件发送后,我的网站突然变得不可用大约 15 分钟,我不知道为什么。

我的网站托管在具有第三方 Web 主机的共享 Windows 2008 服务器上。

这是我的 web.config 文件中的相关部分,出于隐私原因进行了编辑:

<system.net> 
  <mailSettings>
    <smtp deliveryMethod="Network" from="[email protected]">
      <network host="mail.DOMAIN.COM" userName="username" password="password"/>
    </smtp>
  </mailSettings>
</system.net> 

有人对为什么会发生这种情况有任何想法或想法吗?一段时间以来我一直在尝试研究它并谷歌它,但我只是没有想出任何东西。

I have an ASP MVC 2 application, through which I occasionally send emails using SmtpClient.Send(). Typically, emails are sent out in batches of between 1 and 50 emails, with hours or even days passing between batches. I have this all set up so that the emails are actually sending just fine. But, the problem is that when the emails are sent, my site suddenly becomes unavailable for about 15 minutes, and I have no idea why.

My site is hosted on a shared, Windows 2008 server with a third-party web host.

Here is the relevant section in my web.config file, edited for privacy:

<system.net> 
  <mailSettings>
    <smtp deliveryMethod="Network" from="[email protected]">
      <network host="mail.DOMAIN.COM" userName="username" password="password"/>
    </smtp>
  </mailSettings>
</system.net> 

Does anyone have any thoughts or ideas as to why this might be happening? I've been trying to reaserch it and Google it for some time now, but I'm just not coming up with anything.

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

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

发布评论

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

评论(2

毁我热情 2024-09-15 23:15:32

这确实可能有很多不同的事情,但是..

我建议您做的第一件事是在您的站点上启用 ASP.NET 运行状况监控。这有望帮助您了解导致此问题的异常(指南使用健康监控)。

出于显而易见的原因,请确保不要选择邮件提供程序来向您发送异常 - 也许使用 SQL 提供程序或编写写入文件的自定义提供程序。

我还要求您的主机查看事件日志以获取任何可能有价值的信息。

希望有帮助。

This really could be many different things but..

The first thing I suggest you do is enable ASP.NET Health Monitoring on your site. This should hopefully help you gain visibility of the exception that is causing this issue (A guide to using Health Monitoring).

For obvious reasons be sure not to choose the Mail Provider to send you your exceptions - perhaps use the SQL provider or write a custom provider that writes to a file.

I would also ask your hosts to look into the Event Log for any information that may be of value.

Hope that helps.

糖粟与秋泊 2024-09-15 23:15:32

电子邮件可能是一项昂贵的操作。您是否考虑过使用异步电子邮件发送,以便该进程不会阻塞您的主线程?

E-mail can be an expensive operation. Have you considered using the asynchronous e-mail send so that the process does not block your main thread?

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文