Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Send pdf in attachment (Laravel Mail)

Tags:

php

laravel

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?


1 Answers

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

like image 164
Dusan Malusev Avatar answered Dec 08 '25 19:12

Dusan Malusev



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!