1

I am building a web site, and the client wants a newsletter "system" on it. How do I send this kinds of mass (>1000) emails?

I read somewhere that using sendasync method of the smtpclient does the trick. But it constantly gives me an "Email faliure" exception. And, I don't know what to do with that right there...

So, basically my question is, is it ok to send the emails using the SEND method of the smtpclient, but each mail in it's own thread.

for eg.

   NewsletterEmail newsletterEmail = new NewsletterEmail(emailAdress[i], mailSubject, mailBody);
    Thread t = new Thread(new ThreadStart(newsletterEmail.MakeAndSendEmail));
    t.IsBackground = true;
    t.Start();
4

6 回答 6

3

i think , you should rethink about your startegey for sending bulk emails

Creating > 1000 threads is not a good idea , it may even crash your server or it may make your server respond very slow.

于 2010-12-13T18:31:38.200 回答
3

Tell your client about Constant Contact. They are going to handle this much better than you ever could. It's also cheaper than your time.

In the event that fails you have a couple options.

If they already have an email server, leverage that to do the email broadcasting. In other words, relay the mail through that server.

If you can't do that, go download a free email server. I've been using hMailserver. Set it up and relay through it.

If you can't do that, write your own SMTP processing engine. Don't attempt to send the emails directly from ASP.Net. Queue them up in a database and write a windows service to handle the mail broadcasting.

Sending emails can sometimes take several seconds per email. This could completely hose your website while it's trying to handle sending 1000 emails.

A number of mail servers are configured with grey listing, meaning that they require you to send the same email twice in order to prove you aren't a spammer.

Next, getting the DNS appropriately set up can be a PITA. Which is why I suggest constant contact. I have one client that took nearly 5 years to finally get their DNS configured; and yes, I gave them explicit instructions once a year on what to do. Reverse DNS is critical.

Another thing is that some recipient servers have a limit on the number of threads they will accept from you at once. Most mail servers are built to take this into consideration. If you cross that boundary, then the recipient servers will consider you a spammer and take appropriate action.

Another problem area is in sending to a bad address, over and over again. AOL and others will consider you a spammer just for this one thing.

Point is, you really don't want to write this yourself.

于 2010-12-13T18:37:46.533 回答
2

Your best bet would be to have a separate process send the emails. Either have it run on a schedule to check for emails that need to be sent (maybe store the emails in a table?), or, if you don't like the scheduled process idea, then you can have a console application that is started by your website.

Something else to keep in mind is that if you are sending too many emails in a short period of time, it becomes very easy to get black-listed and then none of the emails from your domain will make it to any servers that have you black-listed.

于 2010-12-13T18:34:52.547 回答
0

I've taken two approaches:

1) Lazy, sloppy approach of configuring the asp.net process timeout long enough to complete via Send

2) Create a console app that is spawned by the web app.

于 2010-12-13T18:35:24.423 回答
0

I built a similar system a year or two ago. There's so many things that can go wrong when you send an email programmatically. For this reason, do yourself a favor and seperate the messages from the process of sending them. This way, you can "teach" your system that "badEmail@goodDomian.com" should be ignored or other similar situations.

You can store the message, subject, or whatever level of seperation of data you desire in the database along with a flag for meta-data like "SentOn", "FailedOn", etc. I sent my message one at a time to allow for individual errors to be stored and/or handled. I used SmtpMail.Send(), but whatever method you choose should work as long as you built something smart and recoverable.

于 2010-12-13T19:29:50.443 回答
0

Have a look at the MailChimp API: http://www.mailchimp.com/api/gettingstarted/

于 2010-12-23T17:33:18.563 回答