简体   繁体   中英

Prestashop send mail attachment pdf from html2pdf

Everything is in the title, but to be more precise :

I made an override of Cart.php, in a function i'd like to send a mail with a pdf generated as an attachment.

    $file_attachement['content'] = $voucher->output("useless.pdf", 'E');
    $file_attachement['name'] = 'Voucher.pdf';
    $file_attachement['mime'] = 'application/pdf';

    Mail::Send(
        (int)Context::getContext()->language->id,
        'voucherSend',
        "blabla.",
        array(),
        $customer->email,
        $customer->firstname.' '.$customer->lastname,
        $file_attachement,
        null, _PS_MAIL_DIR_
    );

(Where $voucher is generated via html2pdf)

The mail is sent, but with no attachment unfortunately. However if I change the output option from E to I , supposed to send the pdf directly to the user browser, it works like a charm...

I really don't understand where am I wrong, and if...

尝试使用Tools :: file_get_contents('useless.pdf')而不是$ voucher-> output,并检查是否在正确的位置发送此数据

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM