I am using ActionMailer.net to send emails from my MVC website, the problem is that sending an email some times takes few seconds, and this delay my ajax calls.
I tried to use DeliverAsync() but the same delay is still there, I call the ActionMailer controller action like this:
new EmailController().EntryEmail(CurrentUser, CurrentUser, postText).DeliverAsync();
So my question is, is there a way to call the same Action but in another thread or async.
Notes:
I tried to make the ActionMailer controller inherits from AsyncController but couldn’t because it is already inheriting from another class.
Also for reference I asked this question before: Is it fine to send email from another thread like this?
Why not create a new base class that inherits from AsyncController?
For a simple fire and forget you can use
ThreadPool.QueueUserWorkItem.Personally, I prefer to queue emails and have a separate background thread process the queue. This can be as simple as an “Email” table in a database and a
System.Threading.Timer