将SwiftMailer与Laravel一起使用时出现错误信息

时间:2013-08-15 19:45:11

标签: smtp laravel gmail laravel-4 swiftmailer

我正在尝试使用内置的SwiftMailer捆绑包与Laravel 4发送电子邮件(Gmail)。我已经成功地能够在我的本地服务器上发送和接收电子邮件,在实时,我一直收到此错误消息:< / p>

Failed to authenticate on SMTP server with username "info@myemail.com" using 2 possible authenticators

这是控制器:

public function show_sent() {

    $name = Input::get('name', 'someone');
    $email = Input::get('email');

    // I'm creating an array with user's info but most likely you can use $user->email or pass $user object to closure later
    $user = array(
        'email'=>'info@myemail.com',
        'name'=> $name
    );

    // the data that will be passed into the mail view blade template
    $data = array(
        'detail'=>'Visitor\'s website enquiry',
        'name'  => $user['name'],
        'email'=> $email
    );

    // use Mail::send function to send email passing the data and using the $user variable in the Closure
    Mail::send('emails.registration', $data, function($message) use ($user)
    {
      $message->from('info@myemail.com', 'someone');
      $message->to($user['email'], $user['name'])->subject('New Site Registration');
    });

    $view = View::make('sent');
    $view->title = 'Sent';
    $view->keywords = 'to complete'; 
    $view->description = 'to complete';
$view->body_id = 'sent-page';
    return $view;       
}

mail.php设置:

'driver' => 'smtp',
'host' => 'smtp.gmail.com',
'port' => 465,
'encryption' => 'ssl',

我尝试过使用其他一些gmail帐户,都有相同的错误消息。 任何帮助都会很棒,提前谢谢!

0 个答案:

没有答案