tags:

views:

78

answers:

3

I figure I can either use one mail() command with a large Bcc list or have a loop that sends many individual emails.

I was just going to use Bcc since that is easiest to program and seemed easiest for the server to handle, but then I have to choose some address for the To field. I can just send mail to the websites own address but it would look more sensible to recipients if it was addressed to them. Also, it would be nice to customize each message by saying "Hello [firstname]" at the beginning.

I'm just concerned that sending to too many people will take too long. The maximum number of recipients will be 2000. Users on the website choose a list of people to send to, type a message, and press Send. Would they be waiting forever if it was sending to 2000 people? Would the server choke?

Also what considerations are there regarding mail servers thinking of this as spam?

EDIT: Apparently my client has an SMTP server he says can throttle the outgoing emails. Still not sure though if the PHP would be slow when sending to 1000+ people...

+3  A: 

It's a pretty complex subject with respect to making sure the emails don't start looking like spam. You can really do yourself some favours by hooking it up to something like MailChimp.com and letting them deal with the nasty details for you.

Aidan Kane
I don't see why people are upvoting a blatant advert..?
danp
Because it's a good answer. I spent so much time trying to solve the issue of sending emails to a list, and ended up using MailChimp. Sure there are others. MailChimp's just very developer friendly...
nute
Just saying that it's a much better solution than trying to roll your own. And it's free within the limits of what most people need. Feel free to remove the name of the site but when it comes down to it - this is going to be a perfect solution to most people looking at this topic.
Aidan Kane
+6  A: 

Sending large number of emails at once can really bog down your server, or if its a shared hosting, there is a limit to the number of emails that can be sent over an hour (with bluehost its 700 per hour). So i would recommend you to send emails in chunk.

Create table email_queue with two fields email_to and email_content. Now whenever you wish to send an email, just insert a record into this table with the email address that you wish to send the email to stored in the email_to column and the raw email content in the email_content column.

Next you would create a cron job that runs every hour, that cron job would check the email_queue table to see if it has to send any email, it will pick up 100 records from the email_queue table and send those 100 emails, when the emails have been send those 100 records would be deleted.

This I think would be an ideal way to send out emails in large numbers.

ovais.tariq
+1  A: 

I would actually recommend looking at a third party that can be accessed by an API. Mailing out large numbers of e-mails can be detrimental to your server as it can end up black listed. Check out a company like www.postmark.com or something similar that will throttle your message queue, manage white listed servers, etc.

Mitch C