0

Possible Duplicate:
How to send 100,000 emails weekly?
How to send a multiple emails at a time in cakephp

I have one question to ask you.

I would like to send mail to 100 persons at once using PHP language.

How should I do?

  • select only one email from database and send then loop a process.

  • select 100 email from database and send at once. (Can PHP send to 100 emails at once?)

please explain me.

Thanks

Community
  • 1
  • 1
Giffary
  • 3,060
  • 12
  • 50
  • 71
  • 1
    select 100, put them in a loop. we all hope this is not spam. and depending how your sending the email you may find various limits. –  Dec 17 '11 at 04:54
  • @ajreal Not a duplicate. The code provided in the question you're linking to is _very_ CakePHP-specific. – kba Dec 17 '11 at 04:55
  • Either way could work. If you need more details so do we! Hope this isn't for spam as well. – vdbuilder Dec 17 '11 at 04:55
  • READ the 2nd answer carefully, use BCC – ajreal Dec 17 '11 at 04:55

1 Answers1

1

There is no reason to make multiple queries to the database for something you can select with just one. It's slow and it puts unnecessary stress on your database.

Select everything once and just loop through the results. The mail server will send out the emails as it sees fits if it feels like it can't handle all at once.

kba
  • 19,333
  • 5
  • 62
  • 89
  • @ajreal I'm guessing you gave the downvote. Why? – kba Dec 17 '11 at 04:59
  • there is no indication whether OP are using nested query, and, your while-loop email is the worse. There are other techniques to do this better and efficiently, such as mailq or using an email alias that attach the 100 recipients ... etc etc – ajreal Dec 17 '11 at 05:04
  • I don't see your point regarding nested queries. Also, for 100 emails, there's no need for a mail queue, assuming these don't have to be sent out every five minutes. – kba Dec 17 '11 at 05:09
  • @ajreal: why you not explain 'the other technique' ? – Zul Dec 17 '11 at 05:23
  • Dun ask for trouble, I already indicate 3 methods, BCC, mailq, using email alias. – ajreal Dec 17 '11 at 05:27
  • I have given answer with bcc. I don't know why down vote is given to it (though changing ans from to $to to $bcc ) ? Is there any problem with bcc? – Somnath Muluk Dec 17 '11 at 05:33