laravel使用gmail无法在服务器上发送邮件 [英] laravel send mail on server with gmail not working
本文介绍了laravel使用gmail无法在服务器上发送邮件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
在我的laravel应用程序中,当我创建一个新用户时,我正在发送邮件!因此,在本地主机中,我将gmail smtp与我的gmail帐户和用户名一起使用,并且可以正常工作,但是在服务器上我收到此错误
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 "
这是我的代码
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 ');
});
在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,
推荐答案
通过为应用程序security.google.com/settings/security/apppasswords
这篇关于laravel使用gmail无法在服务器上发送邮件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文