I am building an app that needs to dynamically/programatically know of and use different SMTP settings when sending email.
I'm used to using the system.net/mailSettings approach, but as I understand it, that only allows one SMTP connection definition at a time, used by SmtpClient().
However, I need more of a connectionStrings-like approach, where I can pull a set of settings based on a key/name.
Any recommendations? I'm open to skipping the tradintional SmtpClient/mailSettings approach, and I think will have to...
I needed to have different smtp configurations in the web.config depending on the environment: dev, staging and production.
Here's what I ended up using:
In web.config:
Then in code: