包括外部的php文件到php邮件正文中
问题描述:
if($_POST['mail'])
{
$to_name = $rows['username'];
$to = $rows['email'];
$subject = "Invoice";
$from_name = "abc.com";
$from = "[email protected]";
// 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 protected]";
$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页面显示没有任何邮件!包括外部的php文件到php邮件正文中
答
这是做到这一点的正确方法:
ob_start();
include('invoice.php');
$mail->Body = ob_get_contents();
ob_end_clean();
请不要编辑您的问题,包括一个新的问题。相反,创建一个新问题。 – Matt