Quantcast
Channel: Active questions tagged email - Stack Overflow
Viewing all articles
Browse latest Browse all 29758

Laravel: Email not sending

$
0
0

I try to send email to user using templates. So,before the email sent it should check that the user received email on that day or not. It's like One user should received one mail only in a day so i add if statement which is

if (EmailSave::where('user_id',$user_id)->whereDate('created_at', Carbon::today())->exists()) {

after i add this line the mail is not sending can anyone help me on this. Im new to laravel.

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

                $email_id = $mail->id;
                $user_id = $user->id;


                if( $user->created_at < Carbon::now()->subDays($mail->days)){  //check when the acc create

                    if (EmailSave::where('user_id',$user_id)->whereDate('created_at', Carbon::today())->exists()) {

                        if (EmailSave::where('email_id',$email_id)->where('user_id',$user_id)->count()< 1){  //sent email one time only

                            if (EmailSave::where('email_id',$email_id)->where('user_id',$user_id)->whereDate('created_at', '>', Carbon::now()->addDays(30))) { //mail sent again after 30 days  

                                $mails = new EmailSave;
                                $mails->user_id = $user->id;
                                $mails->email_id =$mail->id;
                                Mail::to($user->email)->send(new Automail($mail));
                                $mails->save();

                            }  
                        }
                    }
                }
            }
          }

Viewing all articles
Browse latest Browse all 29758

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>