我試圖循環選擇下拉菜單併發送電子郵件給多個收件人。每次添加逗號來添加多個電子郵件時,表單都會失敗。 下面是我正在使用的代碼塊,但我想添加更多的電子郵件地址爲'recipient_1'2和3,用逗號分隔。php電子郵件多個收件人
$recipients = array(
'recipient_1' => '[email protected],
'recipient_2' => '[email protected]',
'recipient_3' => '[email protected]'
);
$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>
在你的數組你錯過了「」周圍[email protected],對於初學者。也許只是複製粘貼的東西... – hade 2011-01-24 12:13:32
這實際上只是一個錯誤複製和粘貼到此網站上,我確實在我的代碼中有單引號後[email protected] – cam 2011-01-24 12:28:10