mardi 11 février 2020

Laravel : email send multiples times to one user

I want send email to many users in one time but in this case the mail is sending multiple times to one user it self.

public function create() 
{
    $users = User::where('user_type', 2)->get();
    $auto_email_templates=AutoEmailTemplate::all();


    foreach ($users as $user) {
        foreach($auto_email_templates as $mail){

            if( $user->created_at < Carbon::now()->subDays($mail->days)){

                Mail::to($user->email)->send(new Automail($mail));


                $mail = new EmailSave;
                $mail->user_id = $user->id;
                $mail->email_id =$mail->id;
                $mail->save();

            }
}


from Newest questions tagged laravel-5 - Stack Overflow https://ift.tt/3bsoxaR
via IFTTT

Aucun commentaire:

Enregistrer un commentaire