Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/261.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
PHPMailer-无法加载MsgHTML_Php_Phpmailer - Fatal编程技术网

PHPMailer-无法加载MsgHTML

PHPMailer-无法加载MsgHTML,php,phpmailer,Php,Phpmailer,我使用PHPmailer向客户发送电子凭证。我想把一个动态html文档作为正文发送给用户,但是当我引用这个文件时,我得到了一个错误 我的代码如下: $sessionid = '12345'; $cid = '98765'; require('class.phpmailer.php'); $bodytext1 = "Your Evoucher is attached for ".$row_checkout['name']; $email = new PHPMailer(); $email->

我使用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(文件获取内容('mail.php')

它发送的数据很好,但有一个没有正确字段的实体


有什么建议吗?

您不能将GET参数添加到要加载的文件中。
file\u get\u contents
将加载您的php文件内容,而不是脚本将生成的内容


如果启用了url fopen,您可以将完整的url地址添加到mail.php,但这并不总是最好的主意,或者您可以将此mail.php包含到代码中(但首先要更改内部变量)

您必须使用完整的url(包含协议:
http://..
)或者使用文件名。
mail.php?sid…
不是文件名-这是由apache处理的相对uri。如果使用file\u get\u contents('mail.php'),则发送原始php文件,这可能不是您想要的


您也可以尝试使用
virtual
功能,而不是使用
file\u get\u contents('http://server.com/mail.php?...“

我建议使用获取mail.php的内容,然后应该正确获取内容。(或者在文件获取内容中使用完整url)

您可以包含一个文件并使用变量(会话和购物车ID)。如果在包含的PHP脚本中设置HTML正文,则不会有问题