homepage Welcome to WebmasterWorld Guest from 54.145.252.85
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

    
What do you use to maintain email contact with a userbase?
harleyx

5+ Year Member



 
Msg#: 4282441 posted 2:38 pm on Mar 16, 2011 (gmt 0)

I made the mistake recently of emailing my userbase (approximately 3000 registered users) to let everyone know an old but popular site was again functional.

It wasn't a mistake to email them, but rather how I did it set off delay and bounce filters from gMail and AOL, and probably others.

I tried using PHP's pause() function to spread out the emailing, however when I tested this it simply timed out the script.

So my question, how do those of you who have custom coded emailing functions for newsletters, etc. handle the problem of emailing large numbers of users without setting off these filters with email providers?

 

Kings on steeds

5+ Year Member



 
Msg#: 4282441 posted 12:06 am on Mar 17, 2011 (gmt 0)

are you adding set_time_limit to the script? this is how I would do it.


ini_set('memory_limit','1024M');
set_time_limit(0);
#
$subject = 'Hello, world!';
$body = "Hello {#name},\n this is a test,\n thanks, your site";
$from = "No Reply <no-reply@domain.com>";
$batch_size = 100;
#
$emails = array(array('name'=>'Joe Bloggs','email'=>'joe@blogs.com'), array('name' => 'Jenny Bloggs', 'email'=>'jenny@blogs.com')); //... and so on
#
$blocks = array_chunk($emails,$batch_size);
#
foreach($blocks as $emails){

foreach($emails as $email){
$body = str_replace("{#name}",$email['name'],$body);
mail($to,$subject,$body,"From: $from");
}
sleep(2);
}


Something like this (untested) should send emails in batches of 100 and sleep for 2 seconds this shouldn't trigger rejects, but if it does just sleep for 10 seconds...Also best to run a job like this from CRON.

Alan

harleyx

5+ Year Member



 
Msg#: 4282441 posted 2:38 am on Mar 17, 2011 (gmt 0)

I thought about crons. I'm not familiar with the batch and time limit commands. I'm going to look those up. Sounds promising, thanks much for the examples.

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