questions about mail() (real n00bish)

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
User avatar
m3mn0n
PHP Evangelist
Posts: 3548
Joined: Tue Aug 13, 2002 3:35 pm
Location: Calgary, Canada

questions about mail() (real n00bish)

Post by m3mn0n »

Does this function have any limitations on ammount sent?

I deposited 230 or so emails to my database and when i went to send to them all, only 30 or so showed up as successfully sent.

Here is the coding if it helps...

Code: Select all

<?
// set up a message
$subject = "hi";
$msg = "blah blah";
$headers = "From: Joe\nReply-To: joe@blow.org";
// connect to the database and collect addresses
$db = @mysql_connect("", "", "");
@mysql_select_db("newsletter", $db);
$sql = "select emails from emails";
$res = @mysql_query($sql) or die("Couldn't get addresses.");
// loop through the result set and send mail
while ($email_row = @mysql_fetch_array($res)) {
  // get the recipient address
  $to = $email_rowї'emails'];
  //send the mail
  mail("$to", "$subject", "$msg", "$headers");
  //print a confirmation to the screen
  echo "mail sent to $to <br>";
}
?>
sfhc
Forum Newbie
Posts: 4
Joined: Mon Sep 23, 2002 6:18 am

Post by sfhc »

As far I have seen mail() perform, it can handle huge numbers of e-mails when looped like that.

I'd look at some error in the parameters being passed to mail() or if you have a hosted site, ask them if they limit you at sendmail.

To check for bad parameters:
їphp]
if(!mail(param, param....)){
echo parms to see if any are bad.....
}
ї/php]
?>
Post Reply