Mailbox unavailable. The server response was: 5.7.1 Unable to relay

June 25, 2010

If you’re working with IIS and trying to relay email from your webserver to your exchange server you’ll probably run into this message.
There is a simple line of code you can use to get your smtp mail working that works great.

To start off lets assume that you’ve setup the smtp server on the webserver correctly. And you have the recieve connectors on the exchange server all setup correctly. However you still can’t send email and get the

Mailbox unavailable. The server response was: 5.7.1 Unable to relay

Error of doom. With a simple switch in your code or web.config file you can send out email.

In C# you would add this line of code to send email.

smtpClient.DeliveryMethod =SmtpDeliveryMethod.PickupDirectoryFromIis;

or in your web config.

 
<system.net>

<mailSettings>

<smtp deliveryMethod=”PickupDirectoryFromIis” from=”youremail@site.com”>

<network host=”mysmtpserver.site.com” userName=”username” password=”myPass” port=”25″

defaultCredentials=”true” />

</smtp>

</mailSettings>

</system.net>

Now I hope that people find this post usefull

Got something to say?

You must be logged in to post a comment.