我知道这个问题已经被问过很多次了,但是,我似乎找不到与我的情况相关的解决方案,因为它们主要处理 wordpress。
这是我的邮件表格:
<?php
$to = "email@gmail.com" ;
$from = $_REQUEST['email'] ;
$name = $_REQUEST['name'] ;
$headers = "From: $from";
$subject = "Contact Submission From domain.com";
$fields = array();
$fields{"name"} = "name";
$fields{"title"} = "title";
$fields{"email"} = "email";
$fields{"phone"} = "phone";
$fields{"prefer_phone"} = "pref_phone";
$fields{"prefer_email"} = "pref_email";
$fields{"message"} = "message";
$fields{"referral"} = "referral";
$body = "Here is their submitted message:\n\n"; foreach($fields as $a => $b){ $body .= sprintf("%20s: %s\n\n",$b,$_REQUEST[$a]); }
if($from == '') {print "You have not entered an email, please hit back and resubmit";}
else {
$send = mail($to, $subject, $body, $headers);
if($send)
{header( "Location: http://www.domain.com/sent.html" );}
else
{print "We encountered an error sending your mail, please notify support@domain.com";}
}
?>
电子邮件发送得很好,但我收到了重定向的名义错误:
警告:无法修改标头信息 - 第 23 行 /home/wills5/public_html/send_email.php 中的标头已由(输出开始于 /home/wills5/public_html/send_henry.php:1)发送
编辑:这显然是第 1 行之前的空白,谢谢大家。
如果消息说错误在第 1 行,那么它通常是开头的空格、文本 > 或 HTML