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

How to send mail if they didn't used the module at all in Laravel

$
0
0

Basically, I want send a reminder to the user to used modules in the system. If the didn't used one of the module means need remind them by sending an automated mail. I have created a DB table which contain user_id, module_id and last_used_module. So How i will send the mail to the user.

I try to used null value for last_used_module but its didn't work because last_module_used time is the same with created at and updated at. So, i cant used that.Anyone can help with this?

I got some idea to solve this issue which is if user_id and module_id exist in table means no need to the mail. I don't know hw implement this.

 foreach($ModuleAutoMail as $module) {
                                if($mail->condition_id=='3' ){   

                                $last_used_module = Carbon::parse($module->last_used_module);
                                $DeferenceInDays = Carbon::parse(Carbon::now())->diffInDays($last_used_module);


                                if(is_null($last_used_module)){ 
                                    $ableToSendMail = true;
                                }
                                elseif ($DeferenceInDays > 7) {
                                    $ableToSendMail = false;
                                }
                                else {
                                    if ($emailCheck< 1){  
                                        $ableToSendMail = true;
                                    }
                                }
                            }
                        }
                        if ($ableToSendMail) { //saving and sent email
                        $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 29929


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