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

Laravel: Email need to send again after 30 days

$
0
0

Basically, Now the email sending one time only. I need the email need send again after 30 days. Can anyone help me with this?

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


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

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

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

                if (EmailSave::where('email_id',$email_id)->where('user_id',$user_id)->count()< 1){

                if (condition) { //mail sent again after 30 days  
                    # code...


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

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

                    $mail->save();
                    }  
                }
            } 

Viewing all articles
Browse latest Browse all 29762

Trending Articles



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