使用ob_start()无法使用mail()和header()php修改标头信息

Ami*_*mit -1 html php email header

我相信你们都知道这个错误:

Warning: Cannot modify header information - headers already sent by (output started at /homepages/4/d374499247/htdocs/wp-content/themes/tyler/mail.php:1) in /homepages/4/d374499247/htdocs/wp-content/themes/tyler/mail.php on line 34

这是代码:

if (strpos($email,'@') !== false)  {
    ob_start();
    mail($to,$subject,$message,$headers);
    header("Location: thankyou.html");
    ob_end_flush(); }
Run Code Online (Sandbox Code Playgroud)

谁能在这里提供任何帮助?我只想要邮件()信息,然后转到位置页面

编辑:这是整个代码..

<?php
$to = 'myemail@gmail.com';
$subject = '???? ??????? ?????? ?????';
$message =
'???? ??????? ?????? ?????' . "\n\n" .
'??: ' . $_REQUEST['name'] . "\n\n" .
'???? ????????: ' . $_REQUEST['email'];
$email = $_REQUEST['email'];
$headers = 'From: ' . $email . "\r\n" .
            'Reply-To: ' . $email . "\r\n" .
          'X-Mailer: PHP/' . phpversion();
$headers .= "MIME-Version: 1.0" . "\r\n";
$headers .= "Content-type: text/plain; charset=ISO-8859-1";
// server-validation
if (strpos($email,'@') !== false){
    mail($to,$subject,$message,$headers);
    header("Location: thankyou.html");
} else {
    echo "<p class='error'>????? ????'? ?????.</p>";
}
?>
Run Code Online (Sandbox Code Playgroud)

Nar*_*rek 5

检查您的页面编码.可能是UTF-8 +(带UTF-8签名)

如果没有,那么你需要检查空格.