开发者

Multiple $_POST items

开发者 https://www.devze.com 2023-01-13 17:27 出处:网络
I\'m trying to post multiple email addresses when a form is submitted but it is only sending one. Here is the code.

I'm trying to post multiple email addresses when a form is submitted but it is only sending one. Here is the code.

$email_to = $_POST['emailto'];
$message = stripslashes($message);
$res开发者_如何学运维pond = $_REQUEST['first_name'] ;
mail("$email_to,","Website",$message,"From: $respond","Employment Application");


This looks like PHP, do you have multiple "emailto" fields in your form or is the "emailto" expected to have multiple email addresses?

I'd recommend that (depending on your form design) you use a single input field for the "emailto" where emails are separated by a consistent delimiter (coma, semicolon, etc) and then format the list according to the requested format mail() is expecting. A textarea is a common input field for this type of entry.

I also don't understand why you have the coma at the end.


Have a look at

http://php.net/manual/en/function.mail.php

and make sure your addresses are conform to rfc 2822 (just make a

var_dump($_POST['emailto']);

) and I'm wondering about the additional comma $email_to--->,<----


In your HTML: <input type="text" name="emailto[]" size=20>

Your PHP code:

` $array_email_to = $_POST['emailto'];

foreach ($array_email_to as $email_to) {

$message = stripslashes($message);

$respond = $_REQUEST['first_name'] ;

mail($email_to,"Website",$message,"From: $respond","Employment Application");

}`

0

精彩评论

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