English 中文(简体)
Smtp 例外 - 操作超时
原标题:SmtpException - The operation has timed out
  • 时间:2012-05-24 18:49:23
  •  标签:
  • c#
  • smtp

这是我的代码:

SmtpClient client = new SmtpClient();
client.UseDefaultCredentials = true;

using (client as IDisposable)
{
    foreach (MailAddress addr in Addresses)
    {
        if (addr != null) 
        {
            try 
            {
                message.To.Clear();
                message.To.Add(addr);
                client.Send(message);
            }
            catch (Exception ex) 
            {
                Log(ex);
            }
            i++;
        }
    }
}

每100秒,我记录一个信息 说:

操作已超时 。

这是客户端设置还是在实际邮件服务器上?

最佳回答

当您无法连接到 SMTP 服务器时, 问题就会发生, 这就是为什么此超时信件会发生。 因此当您的客户端无法连接到您的 SMTP 服务器时, 此信件会发生在您的客户端 :

100 second is default value as described below: http://msdn.microsoft.com/en-us/library/system.net.mail.smtpclient.timeout.aspx

可能有几个问题,说明为什么会出现这种问题,即:错误的 SMTP 地址、 SMTP 拒绝、 端口设置、 SSL 配置等, 您需要修正 。

问题回答

我当时也在为这个超时做推理。 问题似乎在于,我试图发送的电子邮件有一个电子邮件地址,但重复了30多次(这是一个真正的收件人电子邮件地址被转换为dev i ) 的德维环境 ) 。 将这个数字( 大约20个)切除解决了这个问题。 显然,这是我自己的 SMTP 服务器所特有的问题,但是如果其他所有邮件都失败了,收件人名单是需要查看的。





相关问题
Anyone feel like passing it forward?

I m the only developer in my company, and am getting along well as an autodidact, but I know I m missing out on the education one gets from working with and having code reviewed by more senior devs. ...

NSArray s, Primitive types and Boxing Oh My!

I m pretty new to the Objective-C world and I have a long history with .net/C# so naturally I m inclined to use my C# wits. Now here s the question: I feel really inclined to create some type of ...

C# Marshal / Pinvoke CBitmap?

I cannot figure out how to marshal a C++ CBitmap to a C# Bitmap or Image class. My import looks like this: [DllImport(@"test.dll", CharSet = CharSet.Unicode)] public static extern IntPtr ...

How to Use Ghostscript DLL to convert PDF to PDF/A

How to user GhostScript DLL to convert PDF to PDF/A. I know I kind of have to call the exported function of gsdll32.dll whose name is gsapi_init_with_args, but how do i pass the right arguments? BTW, ...

Linqy no matchy

Maybe it s something I m doing wrong. I m just learning Linq because I m bored. And so far so good. I made a little program and it basically just outputs all matches (foreach) into a label control. ...

热门标签