laravel在服务器上发送邮件,gmail不起作用


laravel send mail on server with gmail not working

hi在我的laravel应用程序中创建新用户时发送邮件!!所以在localhost中,我将gmailsmtp与我的gmail帐户和用户名一起使用,它正在工作,但在服务器上我收到了这个错误

Swift_TransportException
Expected response code 250 but got code "535", with message "535-5.7.8 Username and Password not    accepted. Learn more at 535 5.7.8 http://support.google.com/mail/bin/answer.py?answer=14257 pn5sm18998642wjc.4 - gsmtp "

这是我的代码

if ($user->save())
        {   
             View::composer('emails.auth.userMail', function($view)
                {
                    $mail = Input::get('email');
                    $pass = Input::get('password');
                  $view->with('username' , $mail )->with('password' , $pass );
                });
            Mail::send('emails.auth.userMail', $data, function($message) use ($user)
                {
                    $message->to(Input::get('email'), '')
                    ->subject('Nouveau compte Happy Road ');

                });

在邮件中.php

'driver' => 'smtp',
'host' => 'smtp.gmail.com',
'port' => 465,
'from' => array('address' => name@gmail.com', 'name' => 'name'),
'encryption' => 'ssl',
'username' => 'mymail@gmail.com',
'password' => 'mypassword',
'sendmail' => '/usr/sbin/sendmail -bs',
'pretend' => false,

通过为应用程序security.google.com/settings/security/apppasswords 生成新密码来解决

我也遇到过同样的问题。要执行此操作,您需要转到

gmail安全部分

然后,您将禁用的安全权限更改为启用。就是这样。