我正在使用 PHPmailer 向客户发送电子凭证。我想将动态 html 文档作为正文发送给用户,但是当我引用此文件时,出现错误。
我的代码如下:
$sessionid = '12345';
$cid = '98765';
require('class.phpmailer.php');
$bodytext1 = "Your Evoucher is attached for ".$row_checkout['name'];
$email = new PHPMailer();
$email->From = 'noreply@xxx.com';
$email->FromName = 'xxx.com';
$email->Subject = 'Your e-voucher for '.$row_checkout['name'];
$email->AddAddress( $row_user['email'] );
$email->MsgHTML(file_get_contents('mail.php?sid='.$sessionid.'&cid='.$cartid));
$file_to_attach = $sessionid.'/'.$bookingid.'.pdf';
$email->AddAttachment( $file_to_attach , $bookingid.'.pdf' );
return $email->Send();
当我运行它时,我收到以下错误:
Warning: file_get_contents(mail.php?sid=12345&cid=98765) [function.file-get-contents]: failed to open stream: No such file or directory in /home4/mission/public_html/xxx.com/evoucher/new/createandmail.php on line 93
但是,如果我不将变量放在 url 中,即
$email->MsgHTML(file_get_contents('mail.php')
它发送得很好,但是带有一个没有正确字段的正文。
有什么建议么?