尝试让我的表单发送电子邮件,但是当我添加这部分代码时
$headers .= "Content-Type: text/html; charset=ISO-8859-1\r\n";
电子邮件不会发送。当我删除它时,电子邮件会发送,但所有标签都会显示出来。知道问题是什么吗?
我的PHP代码如下:
$name = $_POST['name'];
$email = $_POST['email'];
$phone = $_POST['phone'];
$injury = $_POST['injury'];
$message = $_POST['message'];
$myemail = 'example@gmail.com';
$subject = 'Brain Damage Info Free Evaluation Form';
$headers = "From: " . strip_tags($_POST['email']) . "\r\n";
$headers .= "Reply-To: ". strip_tags($_POST['email']) . "\r\n";
$headers .= "MIME-Version: 1.0\r\n";
$headers .= "Content-Type: text/html; charset=ISO-8859-1\r\n";
$email_message = '<html><body>';
$email_message .= '<table rules="all" style="border-color: #666;" cellpadding="10">';
$email_message .= "<tr style='background: #eee;'><td><strong>Name:</strong> </td><td>" . strip_tags($_POST['name']) . "</td></tr>";
$email_message .= "<tr><td><strong>Email:</strong> </td><td>" . strip_tags($_POST['email']) . "</td></tr>";
$email_message .= "<tr><td><strong>Phone:</strong> </td><td>" . strip_tags($_POST['phone']) . "</td></tr>";
$email_message .= "<tr><td><strong>Injury:</strong> </td><td>" . strip_tags($_POST['injury']) . "</td></tr>";
$email_message .= "<tr><td><strong>Description of Injury:</strong> </td><td>" . $_POST['message'] . "</td></tr>";
$email_message .= "</table>";
$email_message .= "</body></html>";
$sent = mail($myemail,$subject,$email_message,$headers);
答案 0 :(得分:0)
我用
$headers = 'From: webmaster@example.com' . "\r\n" .
'Reply-To: webmaster@example.com' . "\r\n" .
'X-Mailer: PHP/' . phpversion();
有了这个我没有得到这样的错误。我认为charset是问题所在。