PHPMailer出现了一些问题,我正在尝试发送带有HTML的简单电子邮件。我开始在电子邮件中而不是作为附件发送图像。这项工作正常,然后我也尝试使用p
标签添加更多内容,这导致无法接收电子邮件。我是否应该设置一种特定的方法来设置HTML正文,或者我只是缺少某些东西?
这很好
require("php/PHPMailer.php");
require("php/SMTP.php");
if (isset($_GET['email'])) {
$emailID = $_GET['email'];
if($emailID = 1){
$mail = new PHPMailer\PHPMailer\PHPMailer();
$mail->IsSMTP(); // enable SMTP
$mail->SMTPDebug = 1; // debugging: 1 = errors and messages, 2 = messages only
$mail->SMTPAuth = true; // authentication enabled
$mail->SMTPSecure = 'ssl'; // secure transfer enabled REQUIRED for Gmail
$mail->Host = "mail.example.com";
$mail->Port = 465; // or 587
$mail->IsHTML(true);
$mail->Username = "myusername";
$mail->Password = "mypassword";
$mail->SetFrom("myemail@example.com");
$mail->Subject = "Test";
$mail->Body = '
<html>
<body>
<img src="https://example.com/images/DocHeader.png" style="margin-left:10%;" width="80%">
</body>
</html>
';
$mail->AddAddress("toemail@example.com");
if(!$mail->Send()) {
echo "Mailer Error: " . $mail->ErrorInfo;
}
else {
echo "Message has been sent";
}
}
}
?>
当我将HTML主体更改为此无效时
<html>
<body>
<img src="https://example.com/images/DocHeader.png" style="margin-left:10%;" width="80%">
<p>Text</p>
</body>
</html>
答案 0 :(得分:-2)
不起作用,因为它不处理表格,或者<p>
只是不显示?