htmlentities忽略<;br>;使用PHPmailer时
几天前,我制作了一个联系表格来发送电子邮件 我有这个:htmlentities忽略<;br>;使用PHPmailer时,php,phpmailer,html-entities,Php,Phpmailer,Html Entities,几天前,我制作了一个联系表格来发送电子邮件 我有这个: If ($validity !='Good@Ripsi'){ $to = "contact-us@xx-xxxx.com"; $subject = "xx xxxx new Subscriber"; $email_address = htmlentities($_GET['email_address']); $headers = "xxxxxxxxxx" . "\r\n" . m
If ($validity !='Good@Ripsi'){
$to = "contact-us@xx-xxxx.com";
$subject = "xx xxxx new Subscriber";
$email_address = htmlentities($_GET['email_address']);
$headers = "xxxxxxxxxx" . "\r\n" .
mail($to,$subject,$email_address,$headers);
header("Location: index.php");
}
这很有效。在我读到这篇文章后,虽然我不打算发送数千封新信,但最好使用PHPmailer,否则它可能会被视为垃圾邮件并被阻止。我对那些邮寄的东西不太了解。所以我读了一篇教程,它运行得很好,但有一点:htmlentities不再起作用,所有的
在接待处都被忽略了
我检查了:$mail->IsHTML(true)代码>
非常感谢您的帮助
以下是使用PHPMailer的代码:
<?php
require "phpmailer/PHPMailer/PHPMailerAutoload.php";
define("DB_HOST","localhost");
define("DB_USERNAME","xxxx_xxxx");
define("DB_PASSWORD","xxxx");
define("DB_NAME","xxxxxx");
$conn = mysqli_connect(DB_HOST,DB_USERNAME,DB_PASSWORD,DB_NAME) or die (mysqli-error());
// Check connection
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
function smtpmailer($to, $from, $from_name, $subject, $body)
{
$mail = new PHPMailer();
$mail->IsSMTP();
$mail->SMTPAuth = true;
$mail->SMTPSecure = 'ssl';
$mail->Host = 'mail.xxxxx.com';
$mail->Port = 465;
$mail->Username = 'newsletter@xxxxx.com';
$mail->Password = 'xxxxxxx';
$mail->IsHTML(true);
$mail->From="newsletter@xxxx.com";
$mail->FromName=$from_name;
$mail->Sender=$from;
$mail->AddReplyTo($from, $from_name);
$mail->Subject = $subject;
$mail->Body = $body;
$mail->AddAddress($to);
if(!$mail->Send())
{
$error ="Error Ocured...";
return $error;
}
else
{
$error = "Please wait!! Your email is being sent... ";
return $error;
}
}
$from = 'newsletter@ts-ripsi.com';
$name = 'xxxxxxx T & S';
$subj = 'Newsletter from xxx and xxxx';
$msg = htmlentities($_GET['message']);
$sqli = "SELECT ID, Email FROM mailing_addresses";
$record = mysqli_query($conn, $sqli);
while ($row = mysqli_fetch_array($record)) {
$to = $row['Email'];
$error=smtpmailer($to,$from, $name ,$subj, $msg);
}
header("Location: index.php");
?>
我不理解IsHTML
的用法。在这种情况下,必须将其设置为false
如果您在使用PHPMailer时遇到代码问题,则应将该代码包括在问题中。完全不清楚您在问什么,因为从上面的代码来看,您只在email\u address
query参数上使用了htmlentities()
。@Phil我刚刚用PHPMailer代码更新了这个问题。message
query参数的一些示例是什么?您希望电子邮件的外观如何?它们实际上看起来怎么样?PHPMailer与htmlentities无关。它只传送你放入正文中的任何内容
。如果你有问题,那是在你的内容中,而不是你用来发送它的过程中。您还使用了一个非常旧的PHPMailer版本,它从来没有帮助过您。