Best way for sending bulk email in asp.net
I have a website and I need to send personalized emails to registered members. This is not an advertizing procedure (spam) rather inform them of their status from time to time. The number of emails that have to be sent in batch are up to 3000. The website is hosted on windows 2008 Server (VPS) and I have installed SMTP on IIS7.
After spending some time reading on how to implement a mechanism for sending mass emails through asp.net, I feel a bit confused.
From what I read I can :
- send them synchronously or asynchronously (new thread) in a loop
- prepare and put them in pickup directory
- create a windows service that would check for an existing queue
- send them from sql server 2008 (I have express).
Can you please suggest the best way to go with?
Would I have problems regarding black-listing my server?
Is there a better way, not mentioned here, for implementing this?
Thanks in advance.
In regards to your server being blacklisted, it doesn't really matter how much you send out "at a time" its more "who you send them to". If you send them to user who don't want them, and they report you as a spammer then you will undoubtedly get blacklisted by one of the many DNS blacklisting sites around.
Always ensure that people opt in first using a double opt-in system, you send an email, if they respond to "activate the account" then you can send them more email, if they don't assume they typed in the wrong address.
In terms of the best way to process, I have always found the best way is to write a small service which runs separately from the site. You really don't want to be sending out emails using the same thread as the IIS service.
If you want to REALLY go for the full blown professional way. You would want to implement some form of message queue system (like ActiveMQ or RabbitMQ) which you send messages around in, and put them into a queue, you would then create a windows process to listen to one of those queues and when a email comes in send it out. That way if your mail processor dies, or is running slowly etc etc you could bring up more processors, connect it to the same queue and more processes share the job (simple distribution).
A slightly less complex way, would be to use a FIFO queue, which would be easily made in a database just save the emails to a table with a datestamp, and send them with a SELECT TOP 10 * FROM OutgoingMail ORDER BY datestamp ASC (remember and use proper indexes) then use a service to just send them out in batches.
Asynch should be avoided if possible from IIS for something like this, you don't want the app pool recycling half way through your job.