开发者

php email multiple recipients

I am trying to to 开发者_JAVA技巧loop through a select drop-down menu and send an email to multiple recipients. Every time I add a comma to add multiple emails the form fails. Here are the chunks of code I am working with, but I would like to add more email address for 'recipient_1' 2 and 3 separated by a comma.

$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>


You're missing a closing quote after the first recipient_1:

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

that'd cause a syntax error.


i had created this kind of things using javascript.. take a look at my example here

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜