【问题标题】:I have problem with the PHPMailer package我对 PHPMailer 包有疑问
【发布时间】: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


【解决方案1】:

首先,你应该检查你的服务器的设置。

尝试使用 mail('your_email@test.com','test','xyz' ); 发送简单的消息;

【讨论】:

  • 我试试这个 $headers .= "MIME-Version: 1.0\r\n"; $headers .= "内容类型: text/html;\r\n";它的工作,但我保留来自 user34213123 的电子邮件
猜你喜欢
  • 1970-01-01
  • 2020-12-30
  • 2017-02-22
  • 2019-05-06
  • 1970-01-01
  • 2010-09-09
  • 2021-05-23
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多