【发布时间】:2018-09-13 16:25:43
【问题描述】:
我收到了这个错误
Expected response code 250 but got code "530", with message "530-5.5.1 Authentication Required. Learn more at\r\n
530 5.5.1 https://support.google.com/mail/?p=WantAuthError 14sm769143wmo.27 - gsmtp\r\n
我使用了 php artisan config:cache 并重新启动了我的服务器,但我仍然收到错误消息。
这是我的 config/mail.php 详细信息
'driver' => env('MAIL_DRIVER', 'smtp'),
'host' => env('MAIL_HOST', 'smtp.gmail.com'),
'port' => env('MAIL_PORT', 587),
'from' => [
'address' => env('MAIL_FROM_ADDRESS', 'Example@gmail.com'),
'name' => env('MAIL_FROM_NAME', 'Example'),
],
'encryption' => env('MAIL_ENCRYPTION', 'tls'),
'username' => env('Example@gmail.com'),
'password' => env('******'),
这是我的用户控制器
<?php
namespace App\Http\Controllers;
use Illuminate\Http\Request;
class UserController extends Controller
{
public function sendMail()
{
\Mail::send('emails.welcome', array('Test'=>'Test User'),
function($message)
{
$message->from('Example@gmail.com', 'Your Application');
$message->to('Example@gmail.com', 'Test')->subject('Your Reminder!');
});
echo"Mail sent successfully...!";
}
}
这是我的视图文件
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Document</title>
</head>
<body>
<h1>hello, {{{$Test}}}!</h1>
</body>
</html>
我的 .env 文件
MAIL_DRIVER= smtp
MAIL_HOST= smtp.gmail.com
MAIL_PORT= 587
MAIL_USERNAME = Example@gmail.com
MAIL_PASSWORD = ******
MAIL_ENCRYPTION = tls
我怎样才能让它工作??
【问题讨论】:
标签: php laravel gmail swiftmailer