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

て烟熏妆下的殇ゞ 提交于 2019-12-04 14:04:44

问题


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.

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

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


回答1:


Try #2... How about using a Exchange Pickup Folder instead? 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.

Configure youur SmtpClient like so:

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



回答2:


Authenticate to the exchange server.

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


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

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




回答3:


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.

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.




回答4:


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



来源:https://stackoverflow.com/questions/444210/how-do-i-send-emails-outside-my-domain-with-exchange-2007-and-c-sharp

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!