Reputation: 5672
not sure it is possible but I am looking for a solution that will queue email messages.
Is there any way to write some sort of web app that will run and send certain amounts of emails to email server for delivery even after I submit my message and close webpage. May be some sort of daemon?
Upvotes: 3
Views: 2319
Reputation: 1518
You can always build a Windows service that connects to a webservice in your web-app which provides the e-mails that are in the queue. That way you can close your browser and the windows-service just grabs an amount of emails for delivery every run.
After delivery you can use a different webservice call to tell the web-app that certain e-mails have been delivered or delayed, so the webapp can control a proper queue.
The reason that i would not recommend using a local mailserver is that it is nearly impossible to get status feedback from sent/bounced/delayed e-mails. If mails bounce or get delayed the local mailserver will reply that to the e-mail address of the sender, and not to your web-app. You would have to build a POP-client to check for bounces, which makes the overall solution more complex than it should have to be. Building a custom polling/sending mechanism does provide status updates on all your e-mails, which imho is especially important if the e-mails are a critical feature of your app.
Upvotes: 0
Reputation: 15663
Presuming generation does not take inordinate amounts of time (ie--too long for your app to process within the web process), you could just switch the SMTP configuration from the default setting of Network
deliver to LocalPickupFolder
. This should be alot quicker from the send angle as you are just writing files, and the mail server will do it's thing to write said files.
Another option would be to manage sending offline. In this case, you would stuff the messages into a database or MSMQ or whatever you feel comfortable with, then write an app to read and send. I tend to prefer command line apps over services here as you don't need real-time network responses and services come with their own set of challenges, such as long running, hard to detect memory leaks and making it hard to resume if the batch crashes. Command line apps are a bit easier to build, test and end up being more flexible in production. You can always schedule them to run via windows scheduled tasks.
Upvotes: 0
Reputation: 2072
Write a windows service that sends the emails. You can use the MSMQ to queue the emails from the web application. The windows service will read from the Message Queue and send the email asynchronously.
Upvotes: 0
Reputation: 6511
A local email server will do exactly that. Once you setup a local email relay server (make sure it will only accept email from the localhost), then just sent email to it and let it handle actually delivering the email.
It will be tons more reliable and configurable than anything you could write. Depending on the platform, you should be able to tune rates of delivery and any other parameters you'd like.
Windows: IIS SMTP Server
Linux: Postfix
Upvotes: 6