gpt4 book ai didi

c# - 使用包括目录的 FQDN 发送电子邮件

转载 作者:太空宇宙 更新时间:2023-11-03 22:16:19 24 4
gpt4 key购买 nike

我正在尝试使用 C# 发送电子邮件。我们的电子邮件提供商建议我使用 mail.example.com/exchange 而不是 mail.example.com

string mailServer;
mailServer = "mail.example.com";
mailServer = "mail.example.com/exchange";

SmtpClient smtpClient = new SmtpClient(mailServer);
smtpClient.DeliveryMethod = SmtpDeliveryMethod.Network;
smtpClient.Credentials = new NetworkCredential("username", "password");
smtpClient.Send("from@example.com", "to@foo.com", "subj", "email body");

mailServer 不包含目录时,经过长时间的停顿,我得到:

System.Net.Mail.SmtpException: Failure sending mail. ---> System.Net.WebException: Unable to connect to the remote server ---> 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

mailServer 确实包含一个目录时,完全没有停顿,我得到:

System.Net.Mail.SmtpException: Failure sending mail. ---> System.Net.WebException: The remote name could not be resolved: 'mail.example.com/exchange'

如何使用 C# 为包含目录的 FQDN 发送电子邮件?

最佳答案

SMTP 不支持目录的概念,因此您可能需要一个知道他们在谈论什么的电子邮件提供商。

关于c# - 使用包括目录的 FQDN 发送电子邮件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5043966/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com