使用 ASP.NET 发送邮件
我使用标准 web.config“mailSettings”作为 ASP.NET 电子邮件的骨干。然而,我发现它的能力越来越有限。例如,我想从许多不同的用户帐户(支持、销售、管理等)发送电子邮件,但 mailSettings 似乎不支持此功能。有什么方法可以避免使用 mailSettings 以便我可以使用多个帐户?有什么缺点(如果没有的话,为什么有人会使用 mailSettings?)
<mailSettings>
<smtp from="[email protected]">
<network host="smtp.gmail.com" port="587" userName="[email protected]" password="abcPassword"/>
</smtp>
</mailSettings>
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="[email protected]">
<network host="smtp.gmail.com" port="587" userName="[email protected]" password="abcPassword"/>
</smtp>
</mailSettings>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果您使用 System.Net.Mail.MailMessage 发送邮件,则应该能够通过将 MailMessage.From 设置为新的 MailAddress 来覆盖 web.config 中的 From。
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.