如何发送带有PDF附件的电子邮件而不保存生成的TCPDF

时间:2018-10-13 10:57:32

标签: laravel email pdf attachment tcpdf

我正在使用TCPDF Laravel软件包生成PDF。以下代码可以发送带有附件的电子邮件,但PDF文件有问题。我无法打开它(也许它已损坏),但是如果我更改...

$attachment = $pdf->output('Reservation Confirmation.pdf', 'E');

从'E'到'D',我可以下载PDF文件,并且可读。请帮助我找出我做错了哪一部分?

<?php

ini_set('max_execution_time', 300);
$html_content = view('pdf.room_reservation_approve', ['reservation' => $this->reservation]);
$pdf = new TCPDF;
$pdf->SetTitle('Reservation Confirmation');
$pdf->AddPage();
$pdf->writeHTML($html_content, true, false, true, false, '');
$attachment = $pdf->output('Reservation Confirmation.pdf', 'E');

return $this->view('emails.room_confirmation_email')
    ->with([
        'name' => $this->guest->name,
        'checkin' => $this->reservation->date_in,
    ])
    ->attachData($attachment, 'Reservation Confirmation.pdf');

enter image description here

0 个答案:

没有答案