rn14 Posted February 26, 2007 Share Posted February 26, 2007 Im attempting to email a letter to around 300 email address's stored in a database. However among the field that stores the email address's are some blank fields. I have created a loop to send an individual email to each address. When I send the email to a test database it works(this would indicate that my code is fine) but this is only for around 10 address's. However when I send it this large number of email address's it only sent to around 10 of the address's. Is it possible to send an email to this many people in this way?? Link to comment https://forums.phpfreaks.com/topic/40150-php-email-problem/ Share on other sites More sharing options...
Threepwood Posted February 26, 2007 Share Posted February 26, 2007 I tried to use php to send massive mail but... for me it's not ok. I mean that php (for my experience) is a programming language to execute short executions. Php send 1 mail in about 2 seconds (if u're lucky) and so it would mean to wait minutes while php send mails... too much for me Link to comment https://forums.phpfreaks.com/topic/40150-php-email-problem/#findComment-194252 Share on other sites More sharing options...
Archadian Posted February 26, 2007 Share Posted February 26, 2007 you can try something like this $sql = mysql_query("SELECT email_address FROM your_table") or die("Could not get the email addresses."); while ($email = mysql_fetch_array($sql)) { mail($email['email_address'], $emailsubject, $emailbody); } Im half asleep but i believe that would work, it will go down the table and send the email subject and email body to each email address in your DB until it runs out of email addresses to send to. I hope this makes sense. Link to comment https://forums.phpfreaks.com/topic/40150-php-email-problem/#findComment-194254 Share on other sites More sharing options...
rn14 Posted February 26, 2007 Author Share Posted February 26, 2007 $sql="SELECT `email`, `first` FROM `test`" or die("Could not get the email addresses."); if ($query=mysql_query($sql)) { while ($req=mysql_fetch_array($query)) { mail($req['email'], $subject, $message, "Dear {$req['first']},"); } } This is the code iv been using so far and it doesnt seem to be sending it to all the names in the database am i missing something. can php send to large numbers of records? Link to comment https://forums.phpfreaks.com/topic/40150-php-email-problem/#findComment-194270 Share on other sites More sharing options...
Archadian Posted February 26, 2007 Share Posted February 26, 2007 yes its possible try this: $sql="SELECT `email`, `first` FROM `test`"; $query=mysql_query($sql) or die("Could not get the email addresses."); while ($req=mysql_fetch_array($query)) { mail($req['email'], $subject, $message, "Dear {$req['first']},"); } Link to comment https://forums.phpfreaks.com/topic/40150-php-email-problem/#findComment-194272 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.