Reputation: 11
I am trying to send an email verification for the registering users but I am getting the following error:
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 v11sm5345109pgt.0 - gsmtp\r\n
I have tried all the possible ways by enabling the "less secure" and other instructions but not understanding the error. please help me to sort out the problem.
My .env
file is :
My Controller:
My 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', '[email protected]'),
'name' => env('MAIL_FROM_NAME', 'Example'), ],
'encryption' => env('MAIL_ENCRYPTION', 'tls'),
'username' => env('[email protected]'),
'password' => env('*******'),
'sendmail' => '/usr/sbin/sendmail -bs',
'pretend' => FALSE,
Upvotes: 0
Views: 1424
Reputation: 3543
The problem is in your mail.php
, use this code instead of your
...
'driver' => env('MAIL_DRIVER', 'smtp'),
'host' => env('MAIL_HOST', 'smtp.gmail.com'),
'port' => env('MAIL_PORT', 587),
'from' => [
'address' => env('MAIL_FROM_ADDRESS', '[email protected]'),
'name' => env('MAIL_FROM_NAME', 'Example')
],
'encryption' => env('MAIL_ENCRYPTION', 'tls'),
'username' => env('MAIL_USERNAME', '[email protected]'),
'password' => env('MAIL_PASSWORD', '*******'),
'sendmail' => '/usr/sbin/sendmail -bs',
'pretend' => FALSE,
...
EDIT:
First parameter of the env()
helper method is name of environment variable
and second one is a fallback value if that variable isn't found. The reason why it didn't work is because Laravel wasn't able to find an environment
variable under the name [email protected]
and *******
.
Upvotes: 1