I'm trying to send an email to a specified user by typing in the URL, but I'm getting the following error:
Swift_TransportException in AbstractSmtpTransport.php line 383:
Expected response code 250 but got code "530", with message "530 5.7.1
Authentication required
So far I'm just trying to get it to work with Gmail. How can I get this to work?
This is what I have so far: mail.php
<?php
return [
'driver' => env('MAIL_DRIVER',' smtp'),
'host' => env('MAIL_HOST', 'smtp.gmail.com'),
'port' => env('MAIL_PORT', 587),
'from' => ['address' =>"[email protected]" , 'name' => "example"],
'encryption' => 'tls',
'username' => env('[email protected]'),
'password' => env('MyPassword'),
'sendmail' => '/usr/sbin/sendmail -bs',
'pretend' => false,
];
This is what I have in the routes:
Route::get('test', function() {
Mail::send('Email.test', [], function ($message) {
$message->to('[email protected]', 'HisName')->subject('Welcome!');
});
});
This is what I have in my controller:
class MailController extends Controller
{
public function Sending_Email()
{
$this->call('GET','Email.test');
return View('Email.test');
}
}
And this is what is in my .env file:
MAIL_DRIVER=smtp
MAIL_HOST=smtp.gmail.com
MAIL_PORT=587
[email protected]
MAIL_PASSWORD=MyPassword
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…