Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mail send not working in cron #74

Closed
ulshamim opened this issue Jul 30, 2015 · 1 comment
Closed

Mail send not working in cron #74

ulshamim opened this issue Jul 30, 2015 · 1 comment

Comments

@ulshamim
Copy link

I used below code global.php file but the mail send is not working,
When I used only mail send code in my controller file that worked. Can you please help me on this.

Event::listen('cron.collectJobs', function() {

    \Cron::add('example1', '/1 * * * *', function() {

        $weekdate = date("Y-m-d", strtotime("+1 week"));
        $results = Inspection::whereBetween('insdate', array($weekdate . ' 00:00:00.00', $weekdate . ' 23:59:59.999'))
                ->where('status', '!=', 'Done')
                ->get();

        foreach ($results as $result) {
            $insname = \Redooor\Redminportal\User::find($result->inspectorname)->first_name . ' ' . \Redooor\Redminportal\User::find($result->inspectorname)->last_name;

          $insemail = \Redooor\Redminportal\User::find($result->inspectorname)->email;

            $data = \Redooor\Redminportal\Product::find($result->product_id)->name;
       \Mail::send('emails.schedule', array('data' => $data), function($message) {
                $message->to($insemail, $insname)->subject('Inspection Schedule Notification');
            });
        }
        return null;
    });
});

This is in log file.

[2015-07-30 09:58:05] production.INFO: Cron run with manager id 331 is with 41 seconds between last run in time. [] []
[2015-07-30 09:58:05] production.INFO: The cron run with the manager id 331 was finished without errors. [] []
@ulshamim
Copy link
Author

Solved.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant