当我发送任何邮件时,这将只返回名称:from:message:subject:,但所有这些字段都是空白的..
<?php
$name = @trim(stripslashes($_POST['name']));
$from = @trim(stripslashes($_POST['email']));
$subject = @trim(stripslashes($_POST['subject']));
$message = @trim(stripslashes($_POST['message']));
$to = 'me@example.com';
$headers = array();
$headers[] = "MIME-Version: 1.0";
$headers[] = "Content-type: text/plain; charset=iso-8859-1";
$headers[] = "From: {$name} <{$from}>";
$headers[] = "Reply-To: <{$from}>";
$headers[] = "Subject: {$subject}";
$headers[] = "X-Mailer: PHP/".phpversion();
mail($to, $subject, $message, $headers);
die;
答案 0 :(得分:0)
在不了解您的环境的情况下,mail
函数将headers参数接受为字符串,而不是数组。
mail($to, $subject, $message, implode("\r\n", $headers));