views:

1494

answers:

4

config file :

<system.net>
<mailSettings>
<smtp from="[email protected]">
<network
host="mail.xxxxxx.com"
port="25"
password="password"
userName="[email protected]"
defaultCredentials="false"
/>
</smtp>
</mailSettings>
</system.net>

I've already tried defaultCredentials="true" but i recieved following message:

System.FormatException: Smtp server returned an invalid response.

how to fix the problem?

+1  A: 

Set the deliveryMethod property on the smtp element to 'network'.

John Sheehan
A: 

tried that already, set it to network

+2  A: 

Where have you placed these elements inside your web.config? They should look like this:

<configuration>
  <system.net>
    <mailSettings>
      <smtp from="[email protected]">
        <network host="mail.xxxxxx.com" port="25" password="password" userName="[email protected]" defaultCredentials="false"/>
      </smtp>
    </mailSettings>
  </system.net>
<configuration>

But based on the exception you're getting it sounds like the config is working but your message is improperly formatted. What does your MailMessage look like? What are you passing as your From, Email, Subject and Body?

Todd Smith
+2  A: 

sorry, had the web.config from the Views folder in ASP.NET MVC open, not the one in the application root - DOH!!!!!

Working fine now :))