PHP表单添加收件人电子邮件


PHP form adding recipent email

我试图发送一个简单的电子邮件表单,一切都很好,但我一直在接收正文消息结束时的收件人电子邮件。我检查了PHP代码,但我找不到为什么要再次显示邮件,这里是PHP代码:

$name = $_POST['name']; 
$company = $_POST['company'];
$website = $_POST['website'];
$visitor_email = $_POST['email']; 
$message = $_POST['message'];
$email_from = 'juano.diy@gmail.com';//<== update the email address
$email_subject = "New Form submission";
$email_body = "You have received a new message from the user $name.'n".
"Company: $company.'n".
"Website: $website.'n".
"Contact Email: $visitor_email.'n".
"Here is the message:'n$message.'n".
"'n".                                                                                                                                                           
$to = "juano.diy@gmail.com";//<== update the email address
$headers = "From: $email_from 'r'n";
$headers .= "Reply-To: $visitor_email 'r'n";
//Send the email!
mail($to,$email_subject,$email_body,$headers);

我将以以下形式介绍这些细节:

Name: xxx
Company: xxx
website: www.xxx.com
email: xxx@live.com
message: Hi testing email

,这是我收到的:

You have received a new message from the user Juan Camilo. 
Company: Blitzar.
Website: www.stiktag.com.
Contact Email: juano.diy@live.com.
Here is the message:
Hi, testing website.
juano.diy@gmail.com

问题是最后一行(juano.diy@gmail.com),为什么我收到的地址,当我已经把它添加到标题,我不想看到它在那里,有什么想法吗?

您的$email_body的最后一行正在连接。

$email_body = "You have received a new message from the user $name.'n". "Company: $company.'n". "Website: $website.'n". "Contact Email: $visitor_email.'n". "Here is the message:'n$message.'n". "'n".

将最后一行"'n".替换为"'n"; -注意分号。