SendEmail.php 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. <?php
  2. namespace App\Jobs;
  3. use App\Mail\GlobalMail;
  4. use Illuminate\Bus\Queueable;
  5. use Illuminate\Queue\SerializesModels;
  6. use Illuminate\Queue\InteractsWithQueue;
  7. use Illuminate\Contracts\Queue\ShouldQueue;
  8. use Illuminate\Foundation\Bus\Dispatchable;
  9. use Illuminate\Support\Facades\Log;
  10. use Illuminate\Support\Facades\Mail;
  11. class SendEmail implements ShouldQueue
  12. {
  13. use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
  14. protected $email;
  15. protected $blade;
  16. protected $subject;
  17. protected $data;
  18. /**
  19. * Create a new job instance.
  20. *
  21. * @return void
  22. */
  23. public function __construct($email, $subject, $data=[], $blade)
  24. {
  25. //
  26. $this->email = $email;
  27. $this->blade = $blade;
  28. $this->subject = $subject;
  29. $this->data = $data;
  30. }
  31. /**
  32. * Execute the job.
  33. *
  34. * @return void
  35. */
  36. public function handle()
  37. {
  38. //
  39. Log::info('SendEmail_to_'.$this->email.'_start');
  40. Mail::to($this->email)->send(new GlobalMail($this->blade, $this->subject, $this->data));
  41. }
  42. }