laravel - Mail methode in a cronjob task command -


hello try send email excel file command it's seems doesn't work

i exception when try run artisan command :

call undefined method illuminate\mail\pendingmail::subject()

someone how resolve problem ? lot in advance

here command :

 public function handle()  {      $user = auth::user();       $licencies = licencies::where('lb_assurance' , '=' , 'lafont')          ->where('created_at' , carbon::today())->get();       $excel_file = excel::create('dailyrecaplicenceslafont',           function($excel) use ($licencies) {              $excel->sheet('excel', function($sheet) use ($licencies) {                 $sheet->fromarray($licencies);              });           });          mail::to($user)             ->subject('licences lafont daily')             ->from('test@test.fr')             ->attach($excel_file , 'lafontdaily.xls')             ->send();          $this->info('lafont task done');     } 

try use mail this:

mail::raw('text e-mail', function ($m) use ($user, $excel_file) {     $m->to($user->email);     $m->subject('licences lafont daily');     $m->from('test@test.fr');     $m->attachdata($excel_file->string() , 'lafontdaily.xls'); }); 

source: laravel 5.1 docs, still valid in large part 5.4

not sure if $excel_file in memory data, better if save file before , call:

 $m->attach($path_to_file , 'lafontdaily.xls'); 

side note: auth::user() should return nothing in command better if use predefined email address in to() function.


Comments

Popular posts from this blog

How to understand 2 main() functions after using uftrace to profile the C++ program? -

c# - Update a combobox from a presenter (MVP) -

How to put a lock and transaction on table using spring 4 or above using jdbcTemplate and annotations like @Transactional? -