mardi 4 juin 2019

Laravel Bulk Send Mail with Notification

I read in laravel documentation :

Once the ShouldQueue interface has been added to your notification, you may send the notification like normal. Laravel will detect the ShouldQueue interface on the class and automatically queue the delivery of the notification:

because of in notification do automatically queue, if i use in my controller:

 public function store(Request $request)
  {
     $users = User::all()
     Notification::send($users, new MyFirstNotification());
   }

and in my notification:

  public function toMail($notifiable)
   {
      return  new custome-emailTo("emails.welcome",$notifiable);
    }

and in custom-mailTo, (it is a mailable class) :

   public function __construct($view2,User $user)
   {
      $this->user = $user;
      $this->view = $view2;
    }

    public function build()
    {
       $this->to($this->user->email);
       return $this->view('emails.welcome');
    }

for me, it work and send to many users,

but my questions are: As stated in the documentation of Laravel,

  1. do it really do queuing for send notification???

with do it,

  1. do i need queue in mailable laravel class for send bulk email?

The Best Regards,



from Newest questions tagged laravel-5 - Stack Overflow http://bit.ly/2XpY4n5
via IFTTT

Aucun commentaire:

Enregistrer un commentaire