2

我正在尝试使用 Iron.io 驱动程序在 Laravel 4 中设置队列电子邮件。我想将一些详细信息传递给电子邮件的主题和发件人属性,但它们似乎没有进入队列请求,并且它们的存在导致电子邮件无法发送(不确定在哪里查找有错误的日志)。但是,简单地使用就Mail::Send()可以了。

这是有问题的代码:

public function handleFeedbackForm() 
{
    $data = array(
        'name_f' => Input::get('name_f'),
        'name_l' => Input::get('name_l'),
        'email' => Input::get('email'),
        'commentType' => Input::get('commentType'),
        'testimonialPublish_answer' => Input::get('testimonialPublish_answer'),
        'comment' => Input::get('message')
    );
    $rules = array(
        'name_f' => 'required',
        'name_l' => 'required',
        'email' => 'required|email',
        'message' => 'required'
    );

    $v = Validator::make(Input::all(), $rules);
    if ($v->passes()) 
    {
        $emailInfo = array('name_f' => Input::get('name_f'), 
                           'name_l' => Input::get('name_l'), 
                            'email' => Input::get('email'));

        Mail::queue('emails.feedback', $data, function($message) use($emailInfo) 
        {
            $recipients = array();
            $form = MailType::find(1);

            foreach ($form->users as $user) 
            {
                $recipients[] = $user->email;
            }

            if (count($recipients) == 0) 
            {
                // Nobody for this field, send to webmaster
                $recipients[] = 'someone@somewhere.com';
            }

            $message->to($recipients)
                ->from($emailInfo['email'])
                ->subject('Foobar Feedback Form Message - ' . $emailInfo['name_f'] . ' ' . $emailInfo['name_l']);
        });

        return Redirect::to('contact')->with('feedbackSuccess', true);
    } 
    else 
    {
        return Redirect::to('contact')->with('feedbackError', true);
    }
}

有任何想法吗?谢谢!

4

0 回答 0