无法发送附件

时间:2014-11-23 12:40:29

标签: php

我有以下代码。 这将完美地发送邮件与正文中所需的内容 但无法发送附件 任何想法可能是错的 我也试过addAttachment和addStringAttachment

以下是我的代码

require_once('html2pdf_v4.03/html2pdf.class.php');

ob_start();

//echo statements for filling the buffer
$echoed_content = ob_get_clean();

$html2pdf = new HTML2PDF('P', 'A4', 'en');

$html2pdf->pdf->SetProtection(array('print'), '1234');

$html2pdf->writeHTML($echoed_content);

$pdfdoc = $html2pdf->Output('','S');

    require('includes/class.smtp.php');

    require('includes/class.phpmailer.php');



    $mail = new PHPMailer(); // create a new object

    $mail->IsSMTP(); // enable SMTP

    $mail->SMTPAuth = true; // authentication enabled

    $mail->SMTPSecure = 'ssl'; // secure transfer enabled REQUIRED for GMail

    $mail->Host = "smtp.gmail.com";

    $mail->Port = 465;

    //$mail->IsHTML(true);

    $mail->Username = "abc@gmail.com";

    $mail->Password = "password";

    $mail->Subject = $title;

    $mail->Body =  $body;

    $filename="abc.pdf";

    $mail->AddStringAttachment($pdfdoc,$filename,$encoding = 'base64', $type = 'application/pdf');

    //$mail->AddAttachment($pdfdoc, '', $encoding = 'base64', $type = 'application/pdf');

    $mail->AddAddress($email);

    if(!$mail->Send()){

        return false;

    }

    return true; 

0 个答案:

没有答案