-1

What I would like to achieve is that I have a .net web application which sends email using the general smtp client instance. My problem is that the creation of client which authenticates and connects to the server is really slow and I would like to improve this part. What I have tried is to create a singleton instance with the client which connects and authenticates on the startup of application and injecting that instance on mail sending. This way I was able to improve the performance but having multithreaded problems like locking and checking auth state. Any idea how I can perform any improvement in this problem.

Sándor Jankovics
  • 738
  • 1
  • 6
  • 19

1 Answers1

1

You could pass off the email sending to a queue and let another process handle that work. The main thread of your web application can then return very quickly providing a better user experience. Hangfire is great for this process - Hangfire - Sending Mail in Background with ASP.NET MVC

Ben D
  • 669
  • 1
  • 11
  • 19