homepage Welcome to WebmasterWorld Guest from
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member
Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
Forum Library, Charter, Moderators: coopster & jatar k

PHP Server Side Scripting Forum

sending newsletter emails

 7:08 pm on Oct 28, 2012 (gmt 0)

So I have a customer database, and if I want to email all of them is this the right way be to loop through all of my customers and use the mail() function?



 8:33 pm on Oct 28, 2012 (gmt 0)

From: [php.net...]

It is worth noting that the mail() function is not suitable for larger volumes of email in a loop. This function opens and closes an SMTP socket for each email, which is not very efficient.

For the sending of large amounts of email, see the PEAR::Mail, and PEAR::Mail_Queue packages.


 2:30 am on Nov 1, 2012 (gmt 0)

GaryK is correct, assuming you are using SMTP delivery via a 3rd party host, in which case you might also use the smtp class from PHPMailer, which makes it much easier to manage this.

If you are using local mail delivery (your mail is sent by the same server that your code is on) things are typically much more efficient.

In my experience, you can push out <1k messages via SMTP mail() just fine on most servers. Over this it is worth looking at other forms of delivery. For mail which is locally handled, I'd say <5k, but do put a usleep or similar delay into the processing to keep server load down - I usually divide out the customers by the acceptable send time (e.g. 3k customers and I'm happy to wait three hours = 0.28s each mail, so insert about 0.2s sleep).

Global Options:
 top home search open messages active posts  

Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved