0

How can I send mass emails with PHP using the built-in mail() function?

I know it is not very efficient, but I need a simple way of sending mass emails.

I know how to send to a single person.

Thanks in advance

ProgramFOX
  • 6,131
  • 11
  • 45
  • 51
Exwolf
  • 5
  • 4
  • How many is "mass" ? And why are you doing it? (there are good mailing list programs out there) – Bart Friederichs Aug 13 '13 at 15:29
  • 1
    MonkeyZeus's solution will work perfectly, as will pulling email addresses from a database with a foreach, or any number of methods of getting multiple names into the to/cc/bcc separated by commas. However, if you're sending a mass email on the order of hundreds or thousands you'll need to pay attention to what your hosting system allows. (limits on the to/cc/bcc per message, or limits on messages per hour, etc.) – lostphilosopher Aug 13 '13 at 15:57

1 Answers1

1

In the to/cc/bcc field you can just separate emails with a comma.

$to = 'email1@yahoo.com, email2@yahoo.com, email3@yahoo.com, email4@yahoo.com, email5@yahoo.com';
MonkeyZeus
  • 20,375
  • 4
  • 36
  • 77
  • This works when we disclose the email addresses of fellow receivers. But what if we want to send emails to 10 users without disclosing the email addresses of the fellow receivers in single iteration. – Nagama Inamdar Dec 02 '13 at 11:04
  • In order to achieve your goal you will have to fill in the proper BCC header as described in this answer: http://stackoverflow.com/a/9525476/2191572 but just make sure to send it `TO` at least one person even if it's something like `no_reply@yoursite.com` – MonkeyZeus Dec 02 '13 at 13:42