Reputation: 5398
I have already changed gmail Less secure app ON (at gmail setting) and my .env
as following
MAIL_DRIVER=smtp
[email protected]
MAIL_HOST=smtp.gmail.com
MAIL_PORT=587
MAIL_PASSWORD=myPass
MAIL_ENCRYPTION=tls
After that my controller as following
try {
Mail::send('admin.users.email', $requestData, function ($message) use ($request) {
$message->from(env('MAIL_ADDRESS'), 'Rejoan');
$message->to(trim($request->input('email')))->subject('Account Updated');
});
}catch (\Exception $e) {
echo $e->getMessage();return;
}
Every tie it is showing following error
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 https://support.google.com/mail/?p=BadCredentials t11sm18420889pjo.21 - gsmtp "
My laravel version is 5.2, What I am doing wrong. Also tried by enable 2 step verification with app password option but not worked.
Is guzzle related issue? my compoer showing "guzzlehttp/guzzle": "^6.5"
When I try with
PHPMailer
library then work but laravel mail not working
Upvotes: 3
Views: 893
Reputation: 5398
After long research it is found that laravel mail not worked with tls
but ssl
is fine. so after changing setting as follows it works
.env
file
MAIL_DRIVER=smtp
[email protected]
MAIL_HOST=smtp.googlemail.com
MAIL_PORT=465
MAIL_PASSWORD=myPass (this should be app password)
MAIL_ENCRYPTION=ssl
normally your email password will not work. generate a app password from here https://security.google.com/settings/security/apppasswords Note: without 2 step verification enable perhaps app password not work
Upvotes: 0
Reputation: 2321
The Error clearly says Username and Password not >accepted "BadCredentials"
Let me guess your MAIL_PASSWORD has a dollar($) or hash(#)
so in your .env
use double quotes
[email protected]
MAIL_HOST=smtp.gmail.com
MAIL_PORT=587
MAIL_PASSWORD="my$Pass#"
like above...
Upvotes: 1