我有一个数组$电子邮件。以下print_r($emails)
输出:
Array
(
[0] => Array
(
[user_email] =>
)
[1] => Array
(
[user_email] => mail_1@gmail.com
)
[2] => Array
(
[user_email] => mail_2@gmail.com
)
)
现在我想向此阵列中的所有电子邮件地址发送电子邮件。我试过了:
foreach($emails as $contact) {
$to = $contact;
$subject = 'the subject';
$message = 'hello';
mail($to, $subject, $message, $headers);
}
我得到的是:Warning: mail() expects parameter 1 to be string, array given
答案 0 :(得分:1)
foreach($emails as $contact) {
$to = $contact['user_email'];
$subject = 'the subject';
$message = 'hello';
mail($to, $subject, $message, $headers);
}