当用户提交表单时,我正在使用 PHPMailer 在 HTML 表单中发送表单数据。fullName
在电子邮件正文中加上引号时会出现语法错误。如果没有引号,则不会显示错误。我是 PHP 新手,当我声明一组代码是 HTML 时,我不确定如何从 PHP 中引用 HTML 表单。这是我的代码:
注意:我正在使用 Dreamweaver 对此进行编码,有时语法更正不正确,但我想在忽略它并对整个文档进行编码之前确定。
<?php
require("class.phpmailer.php");
$mail = new PHPMailer();$mail = new PHPMailer();
$mail->IsSMTP();
$mail->Host = "smtp1.example.com;smtp2.example.com";
$mail->SMTPAuth = true;
$mail->Username = 'smtpusername';
$mail->Password = 'smtppassword';
$mail->From="mailer@example.com";
$mail->FromName="My site's mailer";
$mail->Sender="mailer@example.com";
$mail->AddAddress("email@example.com");
$mail->Subject = "Test 1";
$mail->IsHTML(true);
$mail->Body = "
<h1>Graphics Request</h1>
Name: $_POST['fullName']<br />
";
$mail->AltBody="This is text only alternative body.";
if(!$mail->Send())
{
echo "Error sending: " . $mail->ErrorInfo;;
}
else
{
echo "Letter is sent";
}
?>