c# - Block sending mails -
I am a Windows Forms programmer, we usually do performance programs in a user control. And sometimes you need to send email to functionality.
I have to do something like this: - If I set the flag "This application is running in test mode" then all mail sent applications (from any user control) should be blocked.
I do not want to make any changes to my existing user controls, remember or send mail, I want it to be done only in the container or in the program.cs file instead.
Thanks
You can use, such as an IMailer interface, RealMailer And implemented by TestMailer. While RealMailer will actually send an email, the testing mailer will drop the mail silently. Configure a production configuration that injects realmler, and the test confirmation that injects TestingMailer.
Comments
Post a Comment