Mailbox unavailable. The server response was: 5.7.1 Unable to relay for [email protected]

asp.netEmailIis 7Iis 6

asp.net Problem Overview


I am getting "Mailbox unavailable. The server response was: 5.7.1 Unable to relay for [email protected]" when I try to send the mail using ASP.NET. The site is deployed on IIS7, Windows 2008 server.

The website was working fine on IIS6 and Windows 2003 Server. I deployed it on IIS7, 2008 it has started giving me this error.

Has anybody experienced this before?

asp.net Solutions


Solution 1 - asp.net

Aahh got it... I got it working :)

Thanks Christopher, your suggesion is correct.

But, finding "Default SMTP Virtual Server" was tricky ;)

Even if you use IIS7 to deploy your web site, you have to open IIS6 Manager to configure SMTP server (why?).

I configured SMTP server as follows to make things work:

  1. Open IIS6 Manager using Control Panel --> Administrative Tools.
  2. Open SMTP Virtual Server properties.
  3. On General tab, Set IP address of the Web server instead of "All Unassigned".
  4. In Access tab, click on Relay button, this will open Relay Restrictions dialog.
  5. In relay computers list, add the loopback IP address i.e 127.0.0.1 and IP address of the Web server, so that they can pass/relay emails through the SMTP server.

Solution 2 - asp.net

herein lies the answer... [IIS Settings][1]

[1]: http://codebetter.com/petervanooijen/2006/04/05/using-localhost-as-mailserver-5-7-1-unable-to-relay-for-xxx/ "IIS settings"

IIS-->Default SMTP Virtual Server-->Properties-->Access-->Relay restrictions just add or exclude the IPs you care about, should resolve the issue.

Solution 3 - asp.net

I was facing the identical problem and followed the (very clearly spelled out) steps in Vinod's reply, however this then created a different error:

Unable to read data from the transport connection: net_io_connectionclosed

I did a bit more digging and poking around and (while I'm not sure why this worked) I solved it by:

  • Going back into IIS6.0 management console
  • Open SMTP Virtual Server properties
  • On General tab, changing the 'IP Address:' setting back to '(All Unassigned)'

Not sure why this works, but hopefully will help out someone facing the same problem in the future.

Solution 4 - asp.net

As a picture is worth a thousand words..

When you find the IIS6 manager (I have found that searching for IIS may return 2 results) go to the SMTP server properties then 'Access' then press the relay button.

Then you can either select all or only allow certain ip's like 127.0.0.1

SMTP Relay

Solution 5 - asp.net

Thanks to Vinod for the well presented answer.

I got the same error as Mick Byrne when I followed the steps above. Turning it back to All Unassigned sorted it but I had to tweak a few other things as well:

  • Add the user my site was running under to the users on the Security Tab in SMTP Virtual Server.
  • Changed the value in the mailSettings > network > host attribute in my web.config to the specific server IP (for example 192.168.100.120) as opposed to localhost (which was pointing at 127.0.0.1 in the hosts file).

Hope this saves someone a few mins of messing about.

Solution 6 - asp.net

I was able to fix this issue by changing the mail settings in the system.net portion of my web.config:

<mailSettings>
	<smtp deliveryMethod="Network">
		<network host="yourserver" defaultCredentials="true"/>
	</smtp>
</mailSettings>

Solution 7 - asp.net

If you have Exchange 2010:

(In my case, the error message didn't contain " for [email protected]")

This shows how to add a receive connector: http://exchangeserverpro.com/how-to-configure-a-relay-connector-for-exchange-server-2010/

But I also needed to perform a step found here: http://recover-email.blogspot.com.au/2013/12/how-to-solve-exchange-smtp-server-error.html

> - Go to Exchange Management Shell and run the command > - Get-ReceiveConnector "JiraTest" | Add-ADPermission -User "NT AUTHORITY\ANONYMOUS LOGON" -ExtendedRights > "ms-Exch-SMTP-Accept-Any-Recipient"

While working on this, I ran the following on the affected server's PowerShell console until the error went away:

Send-MailMessage -From "[email protected]" -To "[email protected]" -Subject "Test Email" -Body "This is a test"

Solution 8 - asp.net

Wanted to share what caused the error in my case. Spend couple hours to figure this out, so hopefully it will help to save someone some time.

Strangely enough, the error was raised with the Enable drop directory quota setting being enabled for the domain.

enter image description here

I am not the expert and don't know the technical explanation, but unticking the mentioned setting sorted the problem.

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionVinod T. PatilView Question on Stackoverflow
Solution 1 - asp.netVinod T. PatilView Answer on Stackoverflow
Solution 2 - asp.netChristopher KleinView Answer on Stackoverflow
Solution 3 - asp.netMick ByrneView Answer on Stackoverflow
Solution 4 - asp.netLee EnglestoneView Answer on Stackoverflow
Solution 5 - asp.netNikGView Answer on Stackoverflow
Solution 6 - asp.netpatrickbadleyView Answer on Stackoverflow
Solution 7 - asp.netKind ContributorView Answer on Stackoverflow
Solution 8 - asp.netMorpheusView Answer on Stackoverflow