禁用在asp.net中发送电子邮件 [英] Disable sending emails in asp.net

查看:65
本文介绍了禁用在asp.net中发送电子邮件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否有一种简单的方法来禁止在asp.net中发送邮件?我正在使用Web表单,但是我不想在开发服务器中工作时发送电子邮件.我可以注释掉系统发送电子邮件的每个地方,但我认为有一种更简便的方法.

Is there an easy way to disable sending mails in asp.net? I'm working with webforms but I do not want to send emails while working in my development server. I could comment out every place my system sends an email, but I think there is an easier way to do it.

谢谢

推荐答案

希望您对发送电子邮件"功能进行了集中管理.那很容易.检查您是否在本地/调试:

Hopefully you centralized your "send email" function. Then it is easy. Check if you are local/debug:

HttpContext.Current.Request.IsLocal || HttpContext.Current.IsDebuggingEnabled

并做出适当反应.

我选择实际发送电子邮件,但是我将 to 更改为我的电子邮件帐户,并添加了一条额外的消息,告知谁将 to cc bcc 是(并确保清除所有这些字段,以便不发送任何真实的电子邮件).这样一来,您就可以确定发送的电子邮件是否按预期工作,尤其是当您要切换模板,替换电子邮件中的数据等时.

I choose to actually send the email, but I change the to to my email account and add an extra message about who the to, cc, and bcc in the message were (and ensure you clear all those fields out so no real email is sent). That way you can tell if your send email is working as expected -- especially if you are switching out templates, replacing data in the email, etc.

如果您没有集中使用发送电子邮件"功能...可能是时候咬紧牙关了.

If you didn't centralize your "send email" functions... it may be time to bite the bullet and do it.

这篇关于禁用在asp.net中发送电子邮件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆