Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/261.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
PHPMailer-向mySQL数据库中存储的地址发送多封电子邮件_Php_Phpmailer - Fatal编程技术网

PHPMailer-向mySQL数据库中存储的地址发送多封电子邮件

PHPMailer-向mySQL数据库中存储的地址发送多封电子邮件,php,phpmailer,Php,Phpmailer,我在下面的代码片段中尝试向多个地址发送电子邮件 $recipients = array(); while ($row = mysqli_fetch_array($result)){ $recipients[] = $row; } $recipients = array( 'user_1@domain.com' => 'user_1_name', 'user_2@domain.com' => 'user_2_name', ); foreach($reci

我在下面的代码片段中尝试向多个地址发送电子邮件

$recipients = array();

while ($row = mysqli_fetch_array($result)){   
    $recipients[] = $row;
}

$recipients = array(
   'user_1@domain.com' => 'user_1_name',
   'user_2@domain.com' => 'user_2_name',
);

foreach($recipients as $email => $name)
{
   $mail->addAddress($email, $name);
}
我需要从数据库中获取动态填充内容的电子邮件地址数组,并尝试此操作

$recipients[] = array(
    $row1['email'] => $row1['name']
    );
我得到以下错误,因此我知道我没有正确获得数组。感谢你对我的错误的看法

警告:trim()要求参数1为字符串,数组在 /应用程序/XAMPP

编辑

PHPMailer还触发以下错误,我理解这一点,因为我尝试动态填充的数组没有从数据库获取任何电子邮件地址

邮件程序错误:您必须至少提供一个收件人电子邮件地址


你可以直接得到地址

$recipients = array();

while ($row = mysqli_fetch_array($result)){   
     $mail->addRecipent($row['email'], $row['name']);
}

p、 在美国,最好使用

“我遇到了以下错误”-这是什么?@FunkFortyNiner在你评论时正在编辑!“警告:trim()要求参数1为字符串”-该函数在哪里?它位于class.phpmailer.php中,它是phpmailer中的一个类。我感觉是由于数组中的错误触发的。发送多封电子邮件。。。。由于GDPR,如果没有其他内容,您如何知道这些列在SELECT中,因此在
$row
@riggsfully中可用?对不起,我有疑问,我想没有SELECT当然没有人会在这里着陆。我想不用我绕着桑树丛转,我就可以适应@NaumovSmall Note Bcc addresses not隐形(GDPR)@Naumov,
$first
在这里做什么?