dqqyp90576
2017-07-17 11:03
浏览 39
已采纳

为什么$ header未定义? [重复]

i am trying to send mail using php. i have removed the comment from the SMTP port and mail but Apache throws undefined variable $header in line no.5. what is wrong here?

<?php include "head.php";?>
<?php
$from= "smechailes@gmail.com";
$Headers = "";
$header .= "MIME-Version: 1.0 
";
$header .= "Content-type: text/html; Charset= iso-859-1 
";
$header .= "From: ".$from." 
";
$to = "setok321@gmail.com";
$subject = "test-mail";
$message ="<h1>hello</h1>";
$mail = mail($to, $subject, $message, $header);
echo (int)$mail;
?>
<?php include "foot.php";?>
</div>
  • 写回答
  • 好问题 提建议
  • 追加酬金
  • 关注问题
  • 邀请回答

3条回答 默认 最新

  • dsirr48088 2017-07-17 11:04
    最佳回答

    Replace $Headers = ""; by $header = "";

    Explanation:

    PHP variables are case sensitive.

    You have initialised variable $Headers and assuming it to be $header.

    And concatenating to $header, which is undefined.

    Either change $Headers to $header

    OR

    change

    $header to $Headers at all places.

    评论
    解决 无用
    打赏 举报
查看更多回答(2条)

相关推荐 更多相似问题