SmtpClient class not picking up default parameters from Web.Config file

后端 未结 3 657
半阙折子戏
半阙折子戏 2021-01-14 21:07

config file :






        
相关标签:
3条回答
  • 2021-01-14 21:42

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

    <configuration>
      <system.net>
        <mailSettings>
          <smtp from="YYYYY@xxxxxx.com">
            <network host="mail.xxxxxx.com" port="25" password="password" userName="user@xxxxxx.com" 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?

    0 讨论(0)
  • 2021-01-14 21:46

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

    0 讨论(0)
  • 2021-01-14 21:46

    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 :))

    0 讨论(0)
提交回复
热议问题