PHP电子邮件标题主题问题

时间:2013-02-21 01:24:58

标签: php forms

我一直试图在我的联系表单中添加一个主题行,但我无法让它工作。 必须有一些东西缺失,但我无法弄清楚。 当电子邮件到达时,我可以看到用户的姓名和电子邮件,但我无法获得该主题。

我认为我的PHP脚本出了问题:

<?php
 $names = $_POST['names'];
 $email = $_POST['email_address'];
 $subject = $_POST['subject'];
 $comment = $_POST['comment'];
 $to ='my-email@hotmail.com';

 $message = "";
 $message .= "Name: " . htmlspecialchars($names, ENT_QUOTES) . "<br>\n";
 $message .= "Email: " . htmlspecialchars($email, ENT_QUOTES) . "<br>\n";
 $message .= "Subject: " . htmlspecialchars($subject, ENT_QUOTES) . "<br>\n";

 $message .= "Comment: " . htmlspecialchars($comment, ENT_QUOTES) . "<br>\n";
 $lowmsg = strtolower($message);

 $headers = "MIME-Version: 1.0\r\nContent-type: text/html; charset=iso-8859-1\r\n";
 $headers .= "From: \"" . $names . "\" <" . $email . ">\r\n";
 $headers .= "Reply-To: " .  $email . "\r\n";
 $message = utf8_decode($message);  mail($to, "Note from the Contact Form", $message, $headers);

 if ($message){
   echo 'sent';
 }else{
    echo 'failed';
 }
?>

0 个答案:

没有答案