darkcarnival Posted March 14, 2006 Share Posted March 14, 2006 hi,im want to improve my mailing list script i made for my site.the issue is i have a lot of users on it and the current way have it written now is too slow and i also fear the process is quitting since it takes about a minute to send it out to everyone.now if you wish to see how im currently doing it below is how im doing it:[code]$result = mysql_query("select * from email_list WHERE Status='Subscribed'") or die(mysql_error());$headers = "From: member's monthly update<newsletter@metalstation1.com>\n";//send out email.while ($row = mysql_fetch_array($result)) {set_time_limit(0);@mail($row['Email'], stripslashes($subject), stripslashes($mail_message), $headers);}[/code]now this way works but now that my mailinglist is growing im wondering if theres a better/faster way to send out the newsletter.thanks :) Quote Link to comment Share on other sites More sharing options...
jmag Posted March 14, 2006 Share Posted March 14, 2006 Hey,as it states in the PHP manual the mail() function isn't suitable for looping and sending heaps of mail and isn't resource effective:[a href=\"http://se.php.net/manual/en/function.mail.php\" target=\"_blank\"]http://se.php.net/manual/en/function.mail.php[/a][!--quoteo--][div class=\'quotetop\']QUOTE[/div][div class=\'quotemain\'][!--quotec--]Note: 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.[/quote]so you might want to read up on sending mail with [a href=\"http://pear.php.net/package/Mail\" target=\"_blank\"]PEAR[/a] which would be more suitable for this. Quote Link to comment Share on other sites More sharing options...
darkcarnival Posted March 15, 2006 Author Share Posted March 15, 2006 i dont think i have pear installed on my server or does pear not need anything extra installed for it to work? Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.