目前我有一个功能齐全的电子邮件系统,我想实现我拥有的 Summernote。然而,当我提交表单时,它似乎以文本形式发送 html 代码,因此它显示所有 <> 并且没有特殊格式。所以我认为。它是否正确发送到脚本,因此我回显了它,它显示了没有格式的代码。
发送:
<?php require '../settings.php';
/* Check all form inputs using check_input function */
$name= check_input($_POST['name'], "Enter your name");
$email= check_input($_POST['email']);
$message= $_POST['message'];
$subject= check_input($_POST['subject']);
/* From who and Reply to Who. */
$headers = 'From: '.$name.'\r\n';
$headers .= 'Reply-To: '.$administrationemail.'\r\n';
$headers .= "MIME-Version: 1.0\r\n";
$headers .= "Content-Type: text/html; charset=ISO-8859-1\r\n";
/* Send the message using mail() function */
mail($email, $subject, $message, $headers);
/* Redirect visitor to the thank you page */
header('Location: /mail/');
exit();
}
?>
表格:
<form action="send.php" method="post">
<b>Your Name:</b><input class="form-control" type="text" name="name">
<b>Subject:</b> <input class="form-control" type="text" name="subject">
<b>Recipient E-mail:</b> <input class="form-control" type="text" name="email">
<b>Your Message:</b>
<textarea class="summernote" id="message" name="message"></textarea>
<input name="submit" type="submit" class="btn btn-theme" value="Send it!">
</form>
任何解决这个问题的帮助都会很棒。提前致谢。
我想在电子邮件中显示的内容:
你好约翰·史密斯,
我已收到您的发票,很快就会付款。
来自您的 friend : 史密斯·约翰爵士。
我所看到的内容:
<p><span style="font-weight: bold;">Hello John Smith,</span></p>
<p>I have recieved your invoice and will pay shortly.</p>
<p><span style="font-weight: bold;">From Your Friend:</span></p>
<p> <span style="font-style: italic;">Sir Smith John.</span><span style="font-weight: bold;"><br></span></p>
功能:
function check_input($data, $problem='')
{
$data = trim($data);
$data = stripslashes($data);
$data = preg_replace($wordlist, '****', $data);
if ($problem && strlen($data) == 0)
{
show_error($problem);
}
return $data;
}
最佳答案
您可能需要调整 header ,出于论证目的,我们将使用 PHP 文档中的相同方法。
$headers = 'From: ' . $name . "\r\n";
$headers .= 'Reply-To: ' . $administrationemail . "\r\n";
$headers .= 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
\r\n 必须位于双引号内,因为单引号用于文字字符串。
关于javascript - 通过 PHP 通过电子邮件发送 textarea HTML 代码以显示为 html,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33864382/