使用Iron.io将数据传递到Laravel 4中的排队Mail对象

时间:2013-08-14 22:11:44

标签: php laravel laravel-4 iron

我正在尝试使用Iron.io驱动程序在Laravel 4中设置排队的电子邮件。我想将一些细节传递给电子邮件的Subject和From属性,但它们似乎没有进入队列请求,它们的存在导致电子邮件无法发送(不确定在哪里查找有错误的日志)。但是,只需使用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);
    }
}

有什么想法吗?谢谢!

0 个答案:

没有答案