3

我正在尝试使用带有 Laravel 4 的内置 SwiftMailer 包发送电子邮件(Gmail)。我已经成功地能够在我的本地服务器上发送和接收电子邮件,当我上线时,我不断收到此错误消息:

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 帐户,都有相同的错误消息。任何帮助都会很棒,在此先感谢!

4

0 回答 0