How to send e-mail to multiple recipients from database query (PHP)

前端 未结 7 2470
南方客
南方客 2020-12-29 16:41

I\'m trying to send an e-mail to multiple e-mail address in my database. Here is my current code. It is only working when I specify a single e-mail address, however, I need

7条回答
  •  星月不相逢
    2020-12-29 16:58

    mysql_fetch_array fetches an array with entries corresponding to each of the columns of a single row of your table. In other words, here it's an array containing one user's cEmail column.

    You need to fetch all the values into a single array before calling the mail functions. You could do it like this:

    $dest = array();
    while ($arr = mysql_fetch_array($elist)) {
       $dest[] = $arr['cEmail'];
    }
    

提交回复
热议问题