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

Retrieving ETA (estimated time of arrival) with Google Distance Matrix API and public transit as transport mode -

android - ConstraintLayout: Realign baseline constraint in case if dependent view visibility was set to GONE -

c# - Populating Gridview inside Listview ItemTemplate On Web User Control from Code Behind -