Question

I use the standard web.config 'mailSettings' as the backbone for my ASP.NET emails. However, I find it to being increasingly limited in capability. For example, I want to send emails from many different user accounts (support, sales, management etc.) and it doesn't seem like mailSettings supports this. Is there any way to avoid using mailSettings so that I can use multiple accounts? Any disadvantages (and if not, then why would anyone use mailSettings?)

<mailSettings>
  <smtp from="support@company.com">
    <network host="smtp.gmail.com" port="587" userName="support@company.com" password="abcPassword"/>
  </smtp>
</mailSettings>
Was it helpful?

Solution

If you're sending your mail using a System.Net.Mail.MailMessage, you should be able to override the From in the web.config by setting the MailMessage.From to a new MailAddress.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top