sách gpt4 ai đã đi

smtpclient không hoạt động với máy chủ exchange nhưng hoạt động với máy chủ smtp

In lại 作者:行者123 更新时间:2023-12-04 18:21:43 31 4
mua khóa gpt4 Nike

我写了一个非常基本的类来发送电子邮件。我用 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);

我需要以不同于 smtp 服务器的方式处理交换服务器吗?

请指教
Cảm ơn

1 Câu trả lời

您是否使用了正确的端口号?

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.



从这里撕下: http://www.petri.co.il/ports_used_by_exchange.htm

关于c# - smtpclient 不适用于 Exchange 服务器,但适用于 smtp 服务器,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10539976/

31 4 0
Bài viết được đề xuất: ruby-on-rails - Ruby on Rails - 地理编码器 View
Bài viết được đề xuất: php - 函数参数中的 gmdate() 给出解析错误
Bài viết được đề xuất: sql - Oracle - 从表中选择 n-1 条记录
Bài viết được đề xuất: google-drive-api - WappWolf 如何从 Google Drive 获取通知?
行者123
Hồ sơ cá nhân

Tôi là một lập trình viên xuất sắc, rất giỏi!

Nhận phiếu giảm giá Didi Taxi miễn phí
Mã giảm giá Didi Taxi
Giấy chứng nhận ICP Bắc Kinh số 000000
Hợp tác quảng cáo: 1813099741@qq.com 6ren.com