2016-05-30 156 views
0
 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郵件正文中

+0

請不要編輯您的問題,包括一個新的問題。相反,創建一個新問題。 – Matt

回答

3

這是做到這一點的正確方法:

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