views:

941

answers:

3

I am new to PEAR::Mail, and I am looking for a tutorial that can teach me how to send bulk mails(10K+ emails). "Using mail() in php is not efficient, as its open and close the smtp sockets", this is what I read from internet sources (could not find link now, grrr).

Thus, I am thinking of doing it manually and using mail library that are available for PHP, and I found this PEAR:Mail. On the PEAR site itself, there is "Sending Multiple Recipients" simple tutorial, all recipients will be inserted into an array and then send. Is this the way of sending 10k++ emails? I remember something called "mail queue", but really dont how to use it in PEAR:Mail, can anyone help me?

I dont think Facebook will use for loop to send bulk emails (notifications) right? (well, this is what I thought)

A: 

What are you trying to spam facebook users?

Darkerstar
I am not trying to spam facebook users!! I just want to know how to handle sending millions of emails, thats it.
phplearner
A: 

Be reallyREALLY careful with email stuff, there is a hell of a lot to think about with reguards to spam and data protection. With Pear, there is little useful documentation anywhere it seems, though this may help you:

http://www.phpmaniac.net/wiki/index.php/Pear_Mail

Though maybe you may be better off using something like Campaign Monitor, espescially if you are short on time.

rich
+2  A: 

There's more to bulk email than which language you implement your sender in. As far as the library suggested by rich goes you would be looking at using an SMTP relay to queue and throttle your mails.

As I discovered when I wrote the mass mailer for my company the major problem any bulk mailer faces is the speed at which mails can be punted out into the ether and how it manages retries for mails that have been graylisted or whatever.

So number one you need a good solid SMTP server which can run the mailout job. You will also want some way to throttle the service and monitor it. On a standard Windows Server running IIS and connected to a reasonably large pipe we can clear 5k mails every 15 minutes. If you're looking to implement all that in 48 hours you're going to be pushed.

The fact is there are hard limits to how fast you can push data and further artificial limits imposed by ISPs and so on and so forth. This makes throttling, correct DNS records and the like absolutely vital if you don't want the job to run at snail's pace. The minimum time I could push 10k mails out the door (and the mails are about 50kb in size so that gives you a further idea on throughput) is half an hour and we've got top of the line kit and a connection into a vast distribution pipe backing us up.

In the early days of our company when they used to mail the stuff out from our local broadband it took about 12-14 hours to send 7000 mails. So you've got to understand that physical resources are really important.

Also you will inevitably end up with a minimum of about 50 mails per 10k that just won't deliver first time out. And about 10 of those are not going anywhere ever. The existence of these mails in the retry queue can have a bit of a drag effect on the delivery of further batches of mail, it's minimal but significant.

Also you can't just bang 10k mail files into any server and expect it to be entirely happy about it. We've found through experimentation that dripping 1k mails every three minutes gives us the optimal queue to send ratio. Your mileage will vary depending on your hardware.

Frankly, your choice of software library is the least of your worries at this stage.

Mail_Queue is the related PHP package for managing the queue: http://pear.php.net/package/Mail_Queue
scotts