tags:

views:

109

answers:

4

Hey

I have just over 100 contacts i need to e-mail to

while ($row = mysql_fetch_array($result)){  

 $message = "Hello ".$row['first_name'].", \r\n";
 $message = $message.$_POST['message'];

  if (mail($row['email_address'], $subject, $message, $headers)){
   $sent ++;
  }else{
   $error ++;
  }
 }

Will this run okay? I have looked at other methods (pear, smtp) but wondering if this will run okay?

Thanks

+1  A: 

That will very much depend on your server configuration and a possible "max number of E-Mails per x" limit imposed by your provider. Mail() is not the perfect command for bulk mail but out of general experience I would say that anything up to a few hundred mails is likely to work fine.

Remember to log addresses for which sending fails straight away (possibly due to such a limitation), and setting up a bounce address for the rest.

Pekka
A: 

If you are not aware that your mail server will handle the number, you can split up the work into smaller groups of addresses and add them to a temporary storage (ie. MySQL table).

Then on each page request, you can get some addresses, send the messages and remove them from the temporary table.

PartlyCloudy
+3  A: 

I have recently used the mail function to send to over 100 recipients. So yes it will work.

There where some problems with the function, but a slight delay (100ms) between the mail calls helped solve that problem.

Gamecat
how do i code this delay? thankyou
+1  A: 

Use sleep(int secs) or usleep(int microseconds) for time delay.

You should use usleep for small delays at loop end in every cycle, or you sleep after every 10 mail for example. Depends on your mail server capacity.

pinusnegra