PHP发送电子邮件给多个收件人(标题不发送)

PHP发送电子邮件给多个收件人(标题不发送)

问题描述:

我有一个index.html和一个contacto.php。PHP发送电子邮件给多个收件人(标题不发送)

contacto.php被认为是将用户的信息发送给多个收件人,但它不发送。

这是我的index.html(忽略的JavaScript)

<form action="contacto.php" method="POST"> 

     <fieldset style="margin: 0px 0 0 0"; > 
<br/><br/> <br/><br/> <br/><br/> <br/><br/> 


<input maxlength="255" name="Form testing" size="20" type="hidden" value="Form-name-here" /><br>  

<input value="Nome" onfocus="if (this.value == 'Nome') {this.value = '';}" onblur="if (this.value == '') {this.value = 'Nome';}" maxlength="255" name="name" size="20" type="text" /><br> 

<input value="Telemóvel" onfocus="if (this.value == 'Telemóvel') {this.value = '';}" onblur="if (this.value == '') {this.value = 'Telemóvel';}" id="phone" maxlength="40" name="phone" size="20" type="text" /><br> 

<input onfocus="if (this.value == 'Email') {this.value = '';}" onblur="if (this.value == '') {this.value = 'Email';}" value="Email" id="email" maxlength="80" name="email" size="20" type="text" /><br> 

<input onfocus="if (this.value == 'Localidade') {this.value = '';}" onblur="if (this.value == '') {this.value = 'Localidade';}" value="Localidade" maxlength="255" name="location" size="20" type="text" /><br> 

这是我contacto.php:

<?php 
// Get Data 
$name = strip_tags($_POST['name']); 
$email = strip_tags($_POST['email']); 
$phone = strip_tags($_POST['phone']); 
$location = strip_tags($_POST['location']); 

$headers .="De: Form thingy <[email protected]>"; 
$headers .="CC: Mail1 <[email protected]>"; 
$headers .=", Mail2 <[email protected]>"; 

header("Location: thankyou.html"); //Redirect to Thank You HTML page after email is sent 


// Send message 
mail("[email protected]", "Formulário Facebook Av. Grátis", 
"Name: $name\nEmail: $email\nPhone: $phone\nLocation: $location\n", 
    $headers); 
?> 
+0

更改'$ headers。=“De:表格thingy ”;'到'$ head ers =“From:Form thingy ”;''“De:'不是标准的,使用'”From:....'。 – 2013-03-22 22:16:06

+0

@Fred圣莫里,你是对的。如果我现在改变它,那会起作用吗?我会尽力回报。 – Veronica 2013-03-22 22:21:21

+0

试试看。你测试了他人的答案吗?我张贴在下面。理论上,它应该。 – 2013-03-22 22:23:31

更改后标题位置重定向:

$headers .="De: Form thingy <[email protected]>"; 

为:

$headers ="From: Form thingy <[email protected]>"; 

“德:不是标准作为每PHP手册,使用” 从:....

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

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

全码:

<?php 
// Get Data 
$name = strip_tags($_POST['name']); 
$email = strip_tags($_POST['email']); 
$phone = strip_tags($_POST['phone']); 
$location = strip_tags($_POST['location']); 

$headers ="From: Form thingy <[email protected]>"; 
$headers .="CC: Mail1 <[email protected]>"; 
$headers .=", Mail2 <[email protected]>"; 

// Send message 
mail("[email protected]", "Formulário Facebook Av. Grátis", 
"Name: $name\nEmail: $email\nPhone: $phone\nLocation: $location\n", 
    $headers); 

header("Location: thankyou.html"); //Redirect to Thank You HTML page after email is sent 
?> 
+0

正如“Adidi”所说的,“在发送之前不再提供标题位置重定向”。发送邮件(......) – 2013-03-22 22:29:41

+0

Holy辐条,就这样工作,现在我只需要将这些字段设置为必填字段 – Veronica 2013-03-22 22:45:57

+0

@Veronica很高兴能听到它适合您。它,所以如果发生了什么事情,你仍然会有一个原始的“工作”副本。干杯;-) – 2013-03-22 22:50:16

把发送之前没有

// Send message 
mail("[email protected]", "Formulário Facebook Av. Grátis", 
"Name: $name\nEmail: $email\nPhone: $phone\nLocation: $location\n", 
$headers); 

header("Location: thankyou.html"); //Redirect to Thank You HTML page after email is sent 
+0

刚刚编辑过那个位,回去填写表单,但没有发送任何电子邮件,我可能会缺少一些代码? – Veronica 2013-03-22 21:24:41

+0

你使用你的本地环境吗?或者某些服务器?你有没有php日志到某个地方? – Adidi 2013-03-22 21:27:54

+0

我正在使用我的服务器。我应该使用php日志吗?我不知道如何使用它们。如果我在这里链接到表格的URL? – Veronica 2013-03-22 21:31:05