Sending mail with ASP.NET

不羁岁月 提交于 2019-12-11 01:18:10

问题


I use the standard web.config 'mailSettings' as the backbone for my ASP.NET emails. However, I find it to being increasingly limited in capability. For example, I want to send emails from many different user accounts (support, sales, management etc.) and it doesn't seem like mailSettings supports this. Is there any way to avoid using mailSettings so that I can use multiple accounts? Any disadvantages (and if not, then why would anyone use mailSettings?)

<mailSettings>
  <smtp from="support@company.com">
    <network host="smtp.gmail.com" port="587" userName="support@company.com" password="abcPassword"/>
  </smtp>
</mailSettings>

回答1:


If you're sending your mail using a System.Net.Mail.MailMessage, you should be able to override the From in the web.config by setting the MailMessage.From to a new MailAddress.



来源:https://stackoverflow.com/questions/4979182/sending-mail-with-asp-net

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