Van1310
5 months ago
166
22
Laravel

how to send mail attachment (csv file) in laravel

Posted 5 months ago by Van1310

currenty i am using laravel 5.5 and maatwebsite package 3.1

while sending mail fetching error "Unable to open file for reading [Sales Register 2019 (Cr.xls]"

$file = Excel::download(new UsersExport, 'Sales Register 2019 (Cr.xlsx');

\Mail::raw("In attachment excelfile of sales register ", function($message)

    {

        $message->subject('ExcelFile Participants!');

        $message->from('[email protected]');

        $message->to('[email protected]');

        $message->attach('Sales Register 2019 (Cr.xlsx');

    });

    User::truncate();

    return $file;

Please sign in or create an account to participate in this conversation.