配置文件:
<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>
我已经尝试过defaultCredentials =“true”,但我收到了以下消息:
System.FormatException:Smtp服务器返回了无效的响应。
如何解决问题?
答案 0 :(得分:4)
将smtp元素的deliveryMethod属性设置为“network”。
答案 1 :(得分:4)
现在正常工作:))
答案 2 :(得分:2)
您将这些元素放在web.config中的哪个位置?他们应该是这样的:
<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>
但基于您遇到的异常,听起来配置正在运行,但您的消息格式不正确。你的MailMessage是什么样的?你从From,Email,Subject和Body传递了什么?