The Problem

I recently acquired a new Windows hosting space. Everything ran fine and smooth until I tried to sent an E-Mail from my website. I received the following error: Mailbox unavailable. The server response was: No such user here. Which was weird to me, because I re-used my mailer class which worked fine on other websites. Usually I would setup my Web.Config like this:

<configuration>
  <system.net>
    <mailSettings>
      <smtp>
        <network host="my.host.com" port="25" defaultCredentials="true" />
      </smtp>
    </mailSettings>
  </system.net>
</configuration>

… and I would set the Sender information in code to whatever I want.

The solution

Apparently some servers don’t allow anonymous SMTP. You need to configure an E-Mail account registered on your domain.

Then your Web.config will look:

<configuration>
  <system.net>
    <mailSettings>
      <smtp from="noreply@host.com" deliveryMethod="Network">
        <network host="my.host.com" port="25" defaultCredentials="true" />
      </smtp>
    </mailSettings>
  </system.net>
</configuration>