6

When trying to send out an email in a .NET site, the following error is being encountered:

Mailbox unavailable. The server response was: No such user here

Does this error appear if the code is trying to send to an email address which doesn't exist?

Thanks.

I now have more information about this error. The emails are sent from 'noreply@[domain]'. When the emails are sent to an email address of the same domain, the emails are sent without a problem. This error only appears when the email addresses being sent to are not from the same domain. I don't know if that's any use?

Leah
  • 2,547
  • 5
  • 23
  • 28

5 Answers5

9

This happens when you specify a domain with your NetworkCredentials. If you specify a domain (third argument) then you can only send to valid mailboxes within that domain. Leave it out to be able to send to any address outside the domain.

var client = new SmtpClient("smtp.server.com");
client.UseDefaultCredentials = false;

// The following will be able to send to anyone outside the domain.
client.Credentials = new NetworkCredential("user", "password");

// The following will only work when sending to users on server.com
client.Credentials = new NetworkCredential("user", "password", "server.com");
BrutalDev
  • 6,181
  • 6
  • 58
  • 72
6

Could be that your password is incorrect. I had to reset the password on the mail server, then the error went away.

Sean
  • 14,359
  • 13
  • 74
  • 124
  • That was the case for me. And why wouldn't we receive something like 'Invalid credentials' or 'Authorization failed'? Seeing 'No such user' plus email address of the recipient is really confusing. – Delphi.Boy Feb 14 '16 at 08:30
  • I have the same problem ... and solved by changing password – Ratul Feb 05 '18 at 12:54
3

This may happen when you switch from 2.0 platform to 4.0. As it was explained here you need to tell IIS explicitly that you are not using default credentials and domain. Use the following syntax in web.config:

<network host="mail.younameit.com" port="25"
userName="account@younameit.com" password="youchoose"
defaultCredentials="false" clientDomain=""/>

The last two parameters are most important to fix this problem.

mikryz
  • 480
  • 5
  • 13
1

This Q/A was useful to me in a similar situation. For us, the key fact was that the error only occurred for email addresses on a different domain. I learned that our new webhost/mail server setup is intentionally configured this way. (A previous one with the same hosting co. was not.) Some combination of app code or Web.config settings might have solved our problem, but the most direct way forward was to create a no-reply account on our domain, so that now no-reply@ourdomain.com IS valid, and IS allowed to send to external addresses.

No modifications to code or the Web.config were needed. The latter calls out only "from" and "host" and the credentials are not needed in our hosting environment. (When we override the nominal "from", we need to override it to be some other address that's valid on our domain.

fortboise
  • 1,002
  • 12
  • 10
1

This sounds like an smtp issue

Try setting your smtp server info in the web.config file like this :

<system.net>
        <mailSettings>
            <smtp deliveryMethod="Network">
                <network defaultCredentials="false" host="mail.blah.com" password="xxxx" port="25" userName="ex@blah.com"/>
            </smtp>
        </mailSettings>
</system.net> 

This is a decent article detailing this section of the web.config and how to access it with code behind :

http://dotnetslackers.com/Community/blogs/kaushalparik/archive/2008/09/06/accessing-web-config-file-smtp-mail-settings-programmatically.aspx

BentOnCoding
  • 27,307
  • 14
  • 64
  • 92
  • 1
    Thank you for your response - I am unsure if this would be the issue as the site that the error has appeared on has been live for at least 2 years and they have never received this error message before when emails have been sent out. Could there be any other reason for this error message? – Leah Nov 12 '10 at 09:11