gpt4 book ai didi

asp.net - 使用 ELMAH 在 ASP.Net MVC 5 中出错时发送电子邮件

转载 作者:行者123 更新时间:2023-12-02 13:53:12 24 4
gpt4 key购买 nike

每当我的代码中出现异常时,我都会尝试使用 Elmah 发送电子邮件。这是 web.config 文件中的配置。

<elmah> 
<errorMail from="MyEmailId@gmail.com" to="MyEmailId@gmail.com"
async="true" smtpPort="0" useSsl="true" />
</elmah>
<system.net>
<mailSettings>
<smtp deliveryMethod ="Network">
<network host="smtp.gmail.com" port="587" userName="MyEmailId@gmail.com" password="MyEmailPassword" />
</smtp>
</mailSettings>
</system.net>

现在上面的配置工作正常了。每当我收到异常时,我都会在本地主机中进行测试,我会成功收到一封电子邮件。

问题 1:

Does that mean if I deploy my application with above settings, no matter who ever access my website, if they get an exception I will receive an email.

问题2:

I have added password in above config file. But now everyone can see my password. Is this the right way or I can still send the mail w/o putting my password in config file.

最佳答案

问题 1 的答案:

Exceptions will be caught irrespective of the type of error module you use. So you will definitely receive an email in those exception cases.

问题 2 的答案:

Why are you using your personal mail id? Create a new ID and use it for the purpose, so that even if others see, it doesn't have any effect. Others means only the developers will be able to see, not the public. You can encrypt the web.config file by checking this MSDN article. Also consider encrypting your password and storing it in the web,config file.

关于asp.net - 使用 ELMAH 在 ASP.Net MVC 5 中出错时发送电子邮件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43839711/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com