2010-08-31 85 views
0

我试图在提交表单时发送多个电子邮件地址,但它只发送一个。这是代码。

$email_to = $_POST['emailto']; 
$message = stripslashes($message); 
$respond = $_REQUEST['first_name'] ; 
mail("$email_to,","Website",$message,"From: $respond","Employment Application"); 
+1

你能告诉我们表单的HTML吗? – ircmaxell 2010-08-31 16:50:05

+1

我希望你明白,如果没有保护,这种形式将立即开始被sparse使用 – 2010-08-31 16:58:57

回答

0

这看起来像PHP,你的表单中是否有多个“emailto”字段,或者“emailto”是否有多个电子邮件地址?

我建议您(根据您的表单设计)使用单个输入字段作为电子邮件由一致分隔符(昏迷,分号等)分隔的“emailto”,然后根据请求的格式mail()正在等待。 textarea是这种类型条目的常用输入字段。

我也不明白你为什么最终昏迷。

0

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

你的PHP代码:

` $ array_email_to = $ _ POST [ 'emailto'];

的foreach($ array_email_to为$ EMAIL_TO){

$消息=的stripslashes($消息);

$ respond = $ _REQUEST ['first_name'];

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

}`

+0

为什么不使用BCC字段?这是一个更高效的船载(也更快)... – ircmaxell 2010-08-31 17:03:24

+0

谢谢你。非常感激。 – cbeezy 2010-08-31 17:28:17