SMTP Authentication with config file's MailSettings

时光怂恿深爱的人放手 提交于 2019-11-30 11:16:06

The difference between the coded approach and the web.config only approach is that the latter has defaultCredentials="true" set. That is preventing the username and password from being used to authenticate, with that approach. I think the problem would be solved by setting that to “false” (or removing it completely, because “false” is the default).

The SmtpClient class should use the auth parameters without you needing to explicitly read the username or password out of the config. See http://msdn.microsoft.com/en-us/library/system.net.mail.smtpclient.aspx

Can you post the System.Net segment from your config? Also, can you post the exact error that you're receiving from the SMTP server?

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!