[英]PHPMailer Not Sending Emails - Am I missing something simple?
我正在使用PHPMailer发送HTML电子邮件。 首先调用ob_start
之后,我首先使用HTML和PHP变量设置电子邮件的HTML正文。
这是我的代码:
<?php
ob_start();
?>
..... a bunch of VALID HTML
<?
$body = ob_get_contents();
require_once('class.phpmailer.php');
// Send to Me
$mail = new PHPMailer(true); // the true param means it will throw exceptions on errors, which we need to catch
$mail->IsSendmail(); // telling the class to use SendMail transport
try {
$mail->AddReplyTo('info@example.com', 'Company Name');
$mail->AddAddress('me@example.com', 'My Name');
$mail->SetFrom('info@example.com', 'Company Name');
$mail->Subject = "Contact Form Confirmation";
$mail->AltBody = "This is a contact form submitted through the main website.";
$mail->WordWrap = 50; // set word wrap
$mail->Body = $body;
$mail->IsHTML(true); // send as HTML
$mail->Send(); // Try to send email
} catch (phpmailerException $e) {
echo $e->errorMessage(); //Pretty error messages from PHPMailer
} catch (Exception $e) {
echo $e->getMessage(); //Boring error messages from anything else!
}
// end try
由于某种原因,此行:
$mail->Body = $body;
使电子邮件不发送。 如果我将其替换为:
$mail->Body = "This is a test email.";
电子邮件发送完美。
如果$body
包含的HTML只是一个有效的HTML页面,其头部带有CSS,而没有Javascript或其他内容,为什么电子邮件不发送?
还有另一种方法吗? 请帮忙!!
事实证明,由于某些原因,如果电子邮件包含传真号码,则不会发送。 完全奇怪。 我测试了整个标记,仅删除了10位电话号码后,电子邮件终于通过了。 我不是新手-实际上,这是我删除的唯一文本,并且电子邮件发送正常。
谁看过这个吗??
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.