nealec Posted February 5, 2012 Share Posted February 5, 2012 I am trying to send a list of every name in a database via email but everything i have tried just sends lots of emails with a different name in each email. How can i send every name in one email? Quote Link to comment https://forums.phpfreaks.com/topic/256490-email-list-from-mysql/ Share on other sites More sharing options...
MasterACE14 Posted February 5, 2012 Share Posted February 5, 2012 can you post your code? Quote Link to comment https://forums.phpfreaks.com/topic/256490-email-list-from-mysql/#findComment-1314866 Share on other sites More sharing options...
nealec Posted February 6, 2012 Author Share Posted February 6, 2012 This just sends me multiple emails with a different name in each one rather than all the names in one email. <?php $servername="*******"; $username="*******"; $password="*******"; $conn= mysql_connect($servername,$username,$password)or die(mysql_error()); mysql_select_db("*******",$conn); $result = mysql_query("SELECT name FROM people WHERE mail='yes' "); while($row = mysql_fetch_array($result)){ $to = "[email protected]"; $subject = "People names"; $body = "This is a list of all names in database. $row[name]"; mail($to, $subject, $body); } ?> Quote Link to comment https://forums.phpfreaks.com/topic/256490-email-list-from-mysql/#findComment-1315085 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.