Reputation: 475
Is there an elegant automatic way how not to send MailMessage emails without commenting them out? I don't wan't to modify my code every time I am testing something in pages thats uses MailMessages.
Upvotes: 0
Views: 521
Reputation: 76
a method i have used in the past is to have the configuration for your SMTP server in your web.config
or app.settings.json
and when you are performing local development point it towards a local instance of https://github.com/mailhog/MailHog or equivalent. This will catch all the emails you send without every having to worry about actually letting them out into the world
Your code would remain unchanged which is the best part.
Upvotes: 6