laravel send mail on server with gmail not working

ε祈祈猫儿з 提交于 2020-01-15 06:28:07

问题


hi in my laravel application im sending mail when i create a new user !! so in localhost i use gmail smtp with my gmail account and username and it's working but on the server i got this error

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 "

here is my code

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 ');


                });

in mail.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,

回答1:


solved by genering a new password for the application security.google.com/settings/security/apppasswords




回答2:


I have faced the same problem . To do this action you need to go to your

gmail security section

. Then you will change the security permission disabled to enable. That's it.



来源:https://stackoverflow.com/questions/25769615/laravel-send-mail-on-server-with-gmail-not-working

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!