[LARAVEL] How to send email with attachment from public storage



use Mail;

    Mail::send('layouts.email', ['mail_body'=>$mail_body], 
        function($message) use ($to,$from,$subject,$attachment) {
            $message->to($to, $from)->subject
            ($subject);
            $message->from('youremail@gmail.com','Admin');

            // get attachment from local storage
            $fil_url = 'pubblic/documents/attachment1.pdf';
            $message->attach(base_path('storage/app/'.$file_url));     

            // get attachment from asset folder
            $message->attach(asset('media/documents/attachment2.pdf'));                            
        }
    );

Tidak ada komentar

Diberdayakan oleh Blogger.