如何使用 Exchange 2007 和 c# 在我的域外发送电子邮件

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/444210/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-04 03:35:10  来源:igfitidea点击:

How do I send emails outside my domain with Exchange 2007 and c#

c#smtpexchange-server-2007

提问by jmcd

I am able to send emails using the typical C# SMTP code across Exchange 2007 as long as both the from and to addresses are within my domain.

只要发件人和收件人地址都在我的域内,我就可以在 Exchange 2007 中使用典型的 C# SMTP 代码发送电子邮件。

As soon as I try to send emails outside the domain I get:

一旦我尝试在域外发送电子邮件,我就会得到:

Exception Details: System.Net.Mail.SmtpFailedRecipientException: Mailbox unavailable. The server response was: 5.7.1 Unable to relay

异常详细信息:System.Net.Mail.SmtpFailedRecipientException:邮箱不可用。服务器响应为:5.7.1 无法中继

How can I get exchange to accept my email and send it out to the internet?

我怎样才能让交换接受我的电子邮件并将其发送到互联网?

采纳答案by DavGarcia

Try #2... How about using a Exchange Pickup Folderinstead? They are a faster way to send emails through Exchange because it just creates the email and drops it in the folder, no waiting to connect to the server or waiting for a reply. Plus I think it skips the whole relay issue.

尝试 #2... 改用Exchange Pickup Folder怎么样?它们是通过 Exchange 发送电子邮件的更快方式,因为它只是创建电子邮件并将其放入文件夹中,无需等待连接到服务器或等待回复。另外我认为它跳过了整个中继问题。

Configure youur SmtpClient like so:

像这样配置你的 SmtpClient:

SmtpClient srv = new SmtpClient("exchsrv2007", 25) {
    DeliveryMethod = SmtpDeliveryMethod.SpecifiedPickupDirectory,
    PickupDirectoryLocation = "\exchsrv2007\PickupFolder"
}
...

回答by AlexCuse

You'll need to get your exchange admin to configure exchange to allow sending outside the domain. In my experience they've been reluctant to do so because of spam concerns.

您需要让您的 Exchange 管理员配置 Exchange 以允许在域外发送。根据我的经验,由于担心垃圾邮件,他们一直不愿意这样做。

If its' for limited use, you can set up server-side rules in exchange to forward messages meeting certain criteria outside the domain. You might be able to use VBA in these as well to pretty things up, but I am not sure.

如果它的用途有限,您可以设置服务器端规则作为交换转发域外满足特定条件的邮件。您也可以在这些中使用 VBA 来美化事物,但我不确定。

回答by Zoredache

Authenticate to the exchange server.

对交换服务器进行身份验证。

http://msdn.microsoft.com/en-us/library/system.net.mail.smtpclient.credentials.aspx

http://msdn.microsoft.com/en-us/library/system.net.mail.smtpclient.credentials.aspx



DefaultNetworkCredentials returns empty strings for username etc and causes this exception...

DefaultNetworkCredentials 为用户名等返回空字符串并导致此异常...

Here is an example, and here is anotherof sending authenticated message with System.Net.Mail.

这是一个示例,这是另一个使用 System.Net.Mail 发送经过身份验证的消息。

回答by DavGarcia

Have you set up the exchange server to allow relaysfrom your web server? I had the same problem when switching to Exchange 2007.

您是否设置了交换服务器以允许来自您的 Web 服务器的中继?切换到 Exchange 2007 时我遇到了同样的问题。