嗨,在我的 Laravel 应用程序中,当我创建新用户时,我正在发送邮件!所以在本地主机中,我将 gmail smtp 与我的 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 ');
});
在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
关于php - laravel 在 gmail 无法正常工作的服务器上发送邮件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25769615/