如何在 Blazor 应用程序中设置全局 SmtpDeliveryMethod DeliveryMethod
在 .Net 4.6 Web 应用程序中,我在 web.config 中有一个设置,可以让我为从应用程序发送的所有 smtp 电子邮件全局设置 DeliveryMethod 和 SpecificPickupLocation。
web.config 部分:
<system.net>
<mailSettings>
<smtp deliveryMethod="SpecifiedPickupDirectory">
<specifiedPickupDirectory pickupDirectoryLocation="c:\Temp\" />
</smtp>
</mailSettings>
</system.net>
我的问题是,在没有 web.config 的 Blazor 应用程序中,如何为 smtp 设置类似的全局设置
In a .Net 4.6 web application, I had a setting in web.config that let me globally set the DeliveryMethod and SpecificPickupLocation for all smtp emails I sent from my application.
web.config section:
<system.net>
<mailSettings>
<smtp deliveryMethod="SpecifiedPickupDirectory">
<specifiedPickupDirectory pickupDirectoryLocation="c:\Temp\" />
</smtp>
</mailSettings>
</system.net>
My question is, in a Blazor application where you don't have a web.config, how do you set a similar global setting for smtp
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
具体细节取决于您的 SMTP 实现,但您可以在 appsettings.json 文件中定义类似的配置。
https://learn.microsoft。 com/en-us/aspnet/core/blazor/fundamentals/configuration?view=aspnetcore-6.0
然后,您可以将此配置注入到 SMTP 实现中,类似于此问题: 如何从任何类 blazor 服务器端读取 appsetting.json< /a>
请注意,您可以拥有 appsettings.Production.json 和 appsettings.Development.json 来根据部署配置轻松控制配置。
The specifics would be depenent upon your implementation of SMTP, but you could define similar configuration in your appsettings.json file.
https://learn.microsoft.com/en-us/aspnet/core/blazor/fundamentals/configuration?view=aspnetcore-6.0
You could then inject this configuration into your SMTP implementation, similar to this question: How to read appsetting.json from any class blazor serverside
Note that you can have an appsettings.Production.json, and an appsettings.Development.json to easily control configuration based on deployment configuration.