【问题标题】:including external php file into php mailer body将外部 php 文件包含到 php 邮件正文中
【发布时间】:2016-05-30 12:26:14
【问题描述】:
     if($_POST['mail'])
    {
 $to_name = $rows['username'];
$to = $rows['email'];
$subject = "Invoice";



   $from_name = "abc.com";
 $from = "noreply.com@abc.com";

 // phpMailer
 require_once('phpmailer/PHPMailerAutoload.php');
 $mail = new PHPMailer();

$mail->IsSMTP();
$mail->Host = "smtp.gmail.com"; //enable php socks to make SSL it working
$mail->Port = 465;
$mail->SMTPAuth = true;
$mail->SMTPSecure = 'ssl';    
$mail->Username = "email@gmail.com";
$mail->Password = "password";

$mail->FromName = $from_name;
$mail->From = $from;
$mail->AddAddress($to, $to_name);
$mail->Subject = $subject;
$mail->Body = include'invoice.php';  
$mail->IsHTML(true);    
$result = $mail->Send();
}
?>

而是向我展示 php 页面,它在邮件中什么都不显示!

【问题讨论】:

  • 请不要编辑您的问题以包含新问题。而是创建一个新问题。

标签: email php html


【解决方案1】:

这是正确的做法:

ob_start();
include('invoice.php');
$mail->Body = ob_get_contents();
ob_end_clean();

【讨论】:

猜你喜欢
  • 1970-01-01
  • 2023-03-16
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2011-05-10
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多