0

这是我对这个社区的第一个问题。但是,我长期以来一直在使用它来解决任何技术难题,这对我很有帮助。

无论如何,我的问题是:

我正在从另一个 PHP 文件 shopping_cart.php 加载 mail_contents.php 的 div 中的内容:

$("#mail_contents").load('shopping_cart.php #cart_contents');

当我直接在浏览器中打开 mail_contents.php 时,我也可以看到内容。

但问题是当我尝试使用以下代码通过电子邮件发送此 php 文件的内容时:

.....
$mailer = new PHPMailer();
$mailer->CharSet = 'utf-8';
$mailer->IsHTML(true); 

$mailer->AddAddress($this->UserEmail());

$mailer->Subject = "You have placed an order with ".$this->sitename;

$mailer->From = $this->GetFromAddress();

$mailer->FromName = "POR";   

ob_start();
include 'mail_contents.php';

$content = ob_get_clean();

$mailer->Body = $content;

if(!$mailer->Send()){
$this->HandleError("Failed sending user welcome email.");
return false;
}
return true;
....

我看不到动态加载的内容。我使用 echo 语句在我的 mail_contents.php 文件中添加了一些静态代码,我发现它成功地出现在我的电子邮件中。如果我做错了什么,请指导我。

谢谢是提前!!

4

1 回答 1

0

试试这个:

ob_start();
   include 'mail_contents.php';
$content = ob_get_clean();

$mail->MsgHTML($content, dirname(__FILE__));

告诉我,这是否有效。

于 2013-08-08T07:12:36.907 回答