Mailbox unavailable error

Leah picture Leah · Nov 11, 2010 · Viewed 10.1k times · Source

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?

Answer

BrutalDev picture BrutalDev · Apr 8, 2012

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");