ded Posted January 22, 2009 Share Posted January 22, 2009 I have a database file with about 10k email addresses. Is it good to have a php program to scan through the database 1 record at a time and do the mail() for each record? Is there a better way to do this? Regards, DED Link to comment https://forums.phpfreaks.com/topic/141936-quick-question-about-mail/ Share on other sites More sharing options...
deansatch Posted January 22, 2009 Share Posted January 22, 2009 Yes. But you will have to make the script run in small portions depending on your host. If you run all 10k mail()'s in one go, your host will probably stop the script and give you a warning. Link to comment https://forums.phpfreaks.com/topic/141936-quick-question-about-mail/#findComment-743183 Share on other sites More sharing options...
landavia Posted January 22, 2009 Share Posted January 22, 2009 I have a database file with about 10k email addresses. Is it good to have a php program to scan through the database 1 record at a time and do the mail() for each record? Is there a better way to do this? Regards, DED no.. that would be same as BOMB MAIL if you do that.. but if the reason are reasonable.. that's perhaps do Link to comment https://forums.phpfreaks.com/topic/141936-quick-question-about-mail/#findComment-743184 Share on other sites More sharing options...
dvd420 Posted January 22, 2009 Share Posted January 22, 2009 Hi, Don't you think scanning the db for each record will increase the overhead. Rather you should query the db only once, then use a loop through the result set array for sending out the mail. like, if you are using mySQL then: . . . $query = "SELECT firstname, lastname, address FROM mailing_list;"; //execute the query once, $result is an array $result = mysql_query($query, $link); //Loop for the results while ($row = mysql_fetch_assoc($result)) { // Prepare the message here $msg = "Dear ".$row['firstname'] . $row['lastname']; $msg. = "More stuff here"; mail($row['address'], 'My Subject', $msg); } Link to comment https://forums.phpfreaks.com/topic/141936-quick-question-about-mail/#findComment-743224 Share on other sites More sharing options...
richrock Posted January 22, 2009 Share Posted January 22, 2009 You could use sleep() to create a pause inbetween each email sent. The only problem is that the timing would be the same, and some isp's see this as spamming. I'm not sure how the hosting would react to 10k emails being sent by one person. I have mailing list capabilities on my hosting, but it's limited to 1,500 per list. my 2c worth. Link to comment https://forums.phpfreaks.com/topic/141936-quick-question-about-mail/#findComment-743241 Share on other sites More sharing options...
dvd420 Posted January 22, 2009 Share Posted January 22, 2009 Hi, When I was using this approach to mail, I did two things to overcome the SPAM issue... make the pause interval variable . $count = ($count + 1) % 10; sleep( $count * $interval); . and the second thing was, to change the "From" address, message body & Subject line along with the sleep interval. We can just add some dot(.)s or any char at the end of these strings. Link to comment https://forums.phpfreaks.com/topic/141936-quick-question-about-mail/#findComment-743248 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.