php电子邮件多个收件人

时间:2011-01-24 12:10:03

标签: php email

我正在尝试循环选择下拉菜单并向多个收件人发送电子邮件。每次添加逗号以添加多封电子邮件时,表单都会失败。 以下是我正在使用的代码块,但我想为逗号分隔的'recipient_1'和3添加更多电子邮件地址。

$recipients = array(
'recipient_1' => 'example1@email.com,
'recipient_2' => 'example2@email.com',
'recipient_3' => 'example3@email.com'
);


$to = $recipients[$_REQUEST['recipient']];


 mail($to, $subject, $body, $headers);



<select name="recipient" id="location" tabindex="20">
        <option value="-1">--- Please Select ---</option>
        <option value="recipient_1">City 1</option>
        <option value="recipient_2">City 2</option>
        <option value="recipient_3">City 3</option>
      </select>

2 个答案:

答案 0 :(得分:2)

您在第一个recipient_1后错过了结束语:

'recipient_1' => 'example1@email.com,
                                    ^--here

这会导致语法错误。

答案 1 :(得分:0)

我使用javascript创建了这种东西..看看我的例子here