简体   繁体   中英

Send pdf in attachment (Laravel Mail)

I have this code to get some HTML stored in the column "content" of the "badges" table in a pdf:

 $pdf = app()->make('dompdf.wrapper');
 $pdf->loadHTML($badgeContent->badge->content);

Do you know if is possible to send this pdf in a attachment using Laravel Mail?

You could sent almost any file in attachment

in laravel, create a new mailable inside build paste this code

public function build()
{
    return $this->view('emails.orders.shipped')
                ->attach('/path/to/file');
}

If you need more information on this check laravel's documentation (this code is copied from the laravel's documentation https://laravel.com/docs/5.6/mail#writing-mailables

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