Jump to content


mail() question

  • Please log in to reply
2 replies to this topic

#1 darkcarnival

  • Members
  • PipPipPip
  • Advanced Member
  • 162 posts

Posted 14 March 2006 - 09:23 PM


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:

$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)) {
@mail($row['Email'], stripslashes($subject), stripslashes($mail_message), $headers);

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

#2 jmag

  • Members
  • PipPip
  • Member
  • 22 posts
  • LocationSweden

Posted 14 March 2006 - 09:46 PM


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.

#3 darkcarnival

  • Members
  • PipPipPip
  • Advanced Member
  • 162 posts

Posted 15 March 2006 - 01:12 AM

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

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users