Jump to content

Archived

This topic is now archived and is closed to further replies.

darkcarnival

mail() question

Recommended Posts

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 :)

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
i dont think i have pear installed on my server or does pear not need anything extra installed for it to work?

Share this post


Link to post
Share on other sites

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.