Sending email to all users

Sending mass emails that actually get delivered is not a simple matter at all. Even if your code sends 1000 messages correctly, many if not most of them will get blocked or labeled as spam unless you comply with a long list of mass email best practices. (See also: The FTC’s CAN-SPAM Act – Compliance Guide.)

I recommend that you use (or study the code of) a well-established newsletter plugin with a high rating, as these are more likely to employ best practices for deliverability. You might also install a plugin to send outgoing emails via Mandrill or AmazonSES. (With Mandrill, you can send up to 12,000 emails a month for free.) These services have established relationships with ISPs and spam blacklisting services, so they can better assure the deliverability of your mass emails.