【发布时间】:2020-10-17 00:19:21
【问题描述】:
我正在尝试从 PHPMailer 发送电子邮件。一切正常,但问题是即使在编写$mail->IsHTML(true) 之后,它仍在发送带有 HTML 标签的电子邮件。下面是我发送电子邮件的代码。
<?php
session_start();
if ($_POST['Submit'] == 'Send')
{
if (strcmp(md5($_POST['user_code']),$_SESSION['ckey']))
{
header("Location: sendmail.php?msg=ERROR: Invalid Verification Code");
exit();
}
$to = $_POST['toemail'];
$subject = $_POST['subject'];
$message = $_POST["message"];
$message = isHTML(true);
$fromemail = $_POST['fromemail'];
$fromname = $_POST['fromname'];
$lt= '<';
$gt= '>';
$sp= ' ';
$from= 'From:';
$headers = "From: $from\r\n";
$headers .= "Content-Type: text/html\r\n";
mail($to,$subject,$message,$headers);
header("Location: sendmail.php?msg= Mail Sent!");
exit();
【问题讨论】:
-
您正在覆盖 $message 变量。
$message = $_POST["message"]; $message = isHTML(true);。更好的用户 PHPMailer 库 -
你不是使用 PHPMailer,你这里使用的是PHP自带的
mail函数。 -
coding-style: 不要使用!这个标签指的是一个完全自以为是的主题,因此不再是主题。
标签: php forms styles coding-style phpmailer