如何在laravel 4.2中立即显示发送电子邮件消息

时间:2015-08-16 21:20:17

标签: php laravel laravel-4 laravel-5 queue

我已经尝试过立即显示发送消息,但这需要时间。

我认为队列工作不正常。

在app / config / queue.php中我正在使用

'default'=> '同步'

请帮助我。我很困惑现在这样做。它需要时间来显示成功消息,但我想立即成功消息

       $tasktime = new Tasktime();
        $tasktime->TaskTitle = Input::get('tasktitle');
        $tasktime->Description_Task = Input::get('taskdescribe');
        $tasktime->Estimated_Time = $case;
        $tasktime->Task_Status = Input::get('status');
        $tasktime->Priority_Task = Input::get('priority');
        $tasktime->Assignee_Id = Input::get('Assignee_Id');
        $tasktime->cat_id = Input::get('taskcategories');
        $tasktime->Task_DueDate = Input::get('duedate');
        $tasktime->Task_created_by = Auth::user()->firstname;
        $tasktime->Created_User_Id = Auth::user()->id;
        $tasktime->tasktype = Input::get('tasktype');
    $tasktime->unsc=$cnt;
        $tasktime->save();
        // send mail to assignee id
        $assigneeUser = User::find(Input::get('Assignee_Id'));
        Mail::send(array('html'=>'emails.send'),array('TaskTitle' => Input::get('tasktitle'), 'Priority_Task' => Input::get('priority')), function ($message) use ($assigneeUser) {
            $message->to($assigneeUser->email)->subject('verify');
        });

        return Redirect::to('toggle')->with('message', 'Email has been sent to assignee related to work');

1 个答案:

答案 0 :(得分:0)

排队消息表示您不是立即发送消息。此过程在后台完成。要立即发送电子邮件,您可以使用:

Mail::send(array('html.view', 'text.view'), $data, $callback); 

参考:laravel 4.2 mail doc