SmtpClient 类未从 Web.Config 文件中获取默认参数
配置文件:
<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>
我已经尝试过 defaultCredentials="true" 但收到以下消息:
System.FormatException:Smtp 服务器返回无效响应。
如何解决这个问题?
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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
将 smtp 元素上的 DeliveryMethod 属性设置为“network”。
Set the deliveryMethod property on the smtp element to 'network'.
抱歉,打开了 ASP.NET MVC 中 Views 文件夹中的 web.config,而不是应用程序根目录中的 web.config - DOH!!!!
现在工作正常:))
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 :))
您将这些元素放置在 web.config 中的什么位置? 它们应该看起来像这样:
但根据您收到的异常,听起来配置正在工作,但您的消息格式不正确。 您的邮件消息是什么样的? 您传递的发件人、电子邮件、主题和正文是什么?
Where have you placed these elements inside your web.config? They should look like this:
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?