- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我写了一个非常基本的类来发送电子邮件。我用 smtp 服务器对其进行了测试,它工作正常,但是当我尝试使用我公司的交换服务器时,它给出了这个异常:
SMTP 服务器需要安全连接或客户端未通过身份验证。服务器响应为:5.7.1 客户端未通过身份验证
我的代码如下:
MailMessage mailMessage = new MailMessage("From@company.com", "To@company.com", "Test Subject", "Void body");
SmtpClient smtpClient = new SmtpClient(smtpServerAddress, smtpServerPort);
NetworkCredential credentials = new NetworkCredential(AccountName,Password);
smtpClient.UseDefaultCredentials = false;
smtpClient.Credentials = credentials;
smtpClient.EnableSsl = true;
smtpClient.DeliveryMethod = SmtpDeliveryMethod.Network;
ServicePointManager.ServerCertificateValidationCallback = delegate(object s, X509Certificate certificate, X509Chain chain, SslPolicyErrors sslPolicyErrors) { return true; }; // without this I get: The remote certificate is invalid according to the validation procedure.
smtpClient.Send(mailMessage);
最佳答案
您是否使用了正确的端口号?
Protocol: SMTP/SSL
•Port (TCP/UDP): 465 (TCP)
•Description: SMTP over SSL. TCP port 465 is reserved by common industry practice for secure SMTP communication using the SSL protocol. However, unlike IMAP4, POP3, NNTP, and HTTP, SMTP in Exchange 2000 does not use a separate port for secure communication (SSL), but rather, employs an "in-band security sub-system" called Transport Layer Security (TLS). To enable TLS to work on Exchange 2000, you must install a Computer certificate on the Exchange 2000 server.
关于c# - smtpclient 不适用于 Exchange 服务器,但适用于 smtp 服务器,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10539976/
我正在尝试从本地主机发送邮件.. 在执行此操作时,我有来自不同站点的方法来发送邮件..但是在执行此操作时,我对 smtpClient.send() 感到困惑和smtpClient.SendAsync(
我正在从事一个项目(不幸的是)需要允许的最大框架是 .NET 4。 在这个项目中,我尝试使用 SendAsync() 异步发送电子邮件,但由于某种原因,它发送失败(或者更确切地说,它只是不发送)。简单
考虑到 SmtpClient 有一个我没有使用的 SendAsync 方法,因此假设 StmpClient.Send 是同步的是否安全?我用它来发送带有临时文件附件的电子邮件,想知道我是否可以在之后立
我在多台(不是说:所有)Windows 8.x 机器上面临以下问题: 运行这段代码: var message = new MailMessage(); message.From = new MailA
如标题所述,将“SmtpClient::EnableSsl”设置为 true 的“System::Net::Mail::SmtpClient”需要哪些端口? documentation on the
如果我已将一些电子邮件排队等待通过 System.Net.Mail.SMTPClent 发送,我在哪里可以找到这封邮件?对于 Windows SMTP 客户端,它位于 C:\inetpub\mailr
.NET SmtpClient 对象中的超时默认值是多少?它是什么时间单位(秒、毫秒等)? 最佳答案 默认值为 100,000(100 秒)。 http://msdn.microsoft.com/en
我尝试使用 SmtpClient.Send() 从 c# 发送电子邮件,但它总是进入垃圾箱。如果我从 Outlook 发送它,它工作正常。无论如何要解决这个问题?有人告诉我修改电子邮件标题,但我不知道
我正在尝试使用 C# 创建一个小型应用程序来发送电子邮件,但即使使用端口 587 (GMail) TLS 或 465 (GMail SSL) 我也无法让它工作。我不确定是什么导致了我的问题,我应该编辑
当我使用 SmtpClient 发送电子邮件时,我发现了一个奇怪的行为: 送货时间太长。 已送达两次。 SmtpClient client = new SmtpClient(); client.Hos
我正在使用以下代码发送电子邮件: using (var mailMessage = new MailMessage("from@example.com", "to@example.com")) {
我遇到了一个让我抓狂的问题!!!我有一个用于发送电子邮件的小型 Delphi 7 应用程序(使用 Indy 9 组件套件)并且一切正常。我正在尝试开发一个执行相同操作的 C# 应用程序 (Visual
我的 Smtpclient 正在使用以下设置 SmtpClient client = new SmtpClient(); client.Host = server; client.UseDefault
我的问题是:我需要发现一个 IP 和端口是否正在运行 SMTP 服务。为此,我使用 SMTPClient 尝试打开连接。我正在使用下面的代码。 private static boolean v
我有一个指向我公司邮件服务器的 SmtpClient。我能够成功地向/从该域上的地址发送电子邮件。 但是,我需要为应用程序的用户重置密码和通知。这些用户使用他们自己的电子邮件地址(多个不同的域)注册。
SmtpClient 发送方法返回无效。有什么办法可以得到服务器响应吗?我是否只是假设它是成功的,除非它抛出异常? 我指的是类... http://msdn.microsoft.com/en-us/l
我正在创建每 5 分钟发送一批电子邮件的 Windows 服务。 我想每 5 分钟发送 10-100 封电子邮件。这是极端情况。每 5 分钟发送一次批处理,通常最多包含 10 封电子邮件。 我正在使用
我已经设置了 SmtpClient 类的超时属性,但它似乎不起作用,当我给它一个 1 毫秒的值时,执行代码时超时实际上是 15 秒。我从 msdn 中获取的代码. string to = "jane@
我正在从 Java 向我们的客户发送电子邮件。而且我们的 SMTP 没有任何身份验证。因此,我在 Java 中使用以下代码无需身份验证即可发送: Properties props = new Prop
我有一个 C# 服务 那个连续运行 使用用户凭据(即不是本地系统 - 虽然我想更改但我无法更改)。在大多数情况下,该服务似乎运行正常,但它经常爆炸和 无故重启 (服务管理器设置为在崩溃时重新启动服务)
我是一名优秀的程序员,十分优秀!