Laravel Mail Can't Send - laravel

Failed to authenticate on SMTP server with username "#####gmail.com" using 3 possible authenticators. Authenticator LOGIN returned Expected response code 235 but got code "535", with message "535-5.7.8 Username and Password not accepted```
i have got this error when sending mail.
My .env configaration is
MAIL_DRIVER=smtp
MAIL_HOST=smtp.googlemail.com
MAIL_PORT=465
MAIL_USERNAME=#####gmail.com
MAIL_PASSWORD=######
MAIL_ENCRYPTION=ssl

you need to configure .env like this
MAIL_DRIVER=smtp
MAIL_HOST=smtp.gmail.com
MAIL_PORT=587
MAIL_USERNAME=myemail#gmail.com
MAIL_PASSWORD=password
MAIL_ENCRYPTION=tls
Don't forget to run php artisan config:cache after you make changes in your .env file.
NOTE:- you need to allow less secure apps from "Google Account" - https://myaccount.google.com/ - Settings - Less secure app access (Turn On)

In your case, please try to enable less secure app.
Turn turn off 2 step verification and enable less secure app (as follows)
go to gmail.com
my account
and enable
Allow less secure apps: ON

Related

Failed to send message from Laravel controller

I tried to send an email from a Laravel controller, but it's showing this error. I'm not using a two step verified Gmail account. Most tutorials use the "enable less secure app" settings, but I can't enable that option in my account.
this is my env file
MAIL_MAILER=smtp
MAIL_HOST=smtp.googlemail.com
MAIL_PORT=465
MAIL_USERNAME=******
MAIL_PASSWORD=******
MAIL_ENCRYPTION=ssl
MAIL_FROM_ADDRESS=********
MAIL_FROM_NAME="${APP_NAME}"
Please use your google app password in MAIL_PASSWORD

How to solve the Sendgrid STMP Error 250 response in Laravel

I am using Sendgrid for the mail service.
My Account is two factor authentication is enabled.
My .env
MAIL_DRIVER=smtp
MAIL_HOST=smtp.sendgrid.net
MAIL_PORT=587
MAIL_USERNAME=S4gYKuoPRBaOAy7qT__J8w
MAIL_PASSWORD=SG.APIKEYPASSWORD
MAIL_ENCRYPTION=tls
MAIL_FROM_NAME="Xyz Name"
MAIL_FROM_ADDRESS=xyz#xyz.com
If I execute the mail then I am getting below error.
Swift_TransportException : Failed to authenticate on SMTP server with username "S4gYKuoPRBaOAy7qT__J8w" using 2 possible authenticators. Authenticator LOGIN returned Expected response code 250 but got an empty response. Authenticator PLAIN returned Expected response code 250 but got an empty response.
And If I disable the two-factor authentication then it works with the UserName and Password of the account but sendgrid will suspend my account if I do it like this.
Can anyone faced this issue. if yes then please let me know how you solved the problem.
Try using the literal value 'apikey' as the MAIL_USERNAME, and the key from an API Key that you create in Settings >> API Keys as the MAIL_PASSWORD.
They are now enforcing 2FA, and auth with keys instead of a user/password when using 2FA, starting Nov 18, 2020. I just changed over and this worked for me.
For example,
MAIL_DRIVER=smtp
MAIL_HOST=smtp.sendgrid.net
MAIL_PORT=587
MAIL_USERNAME=apikey
MAIL_PASSWORD=SG.xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
We should highlight this one
MAIL_USERNAME=apikey
The string "apikey" is literally the MAIL_USERNAME` for all

laravel "error when sending email fwrite(): send of 18 bytes failed with errno=10054"

I am using laravel I got this error when I send emails
fwrite(): send of 18 bytes failed with errno=10054 An existing connection was forcibly closed by the remote host.
it was working normally
this is my configuration
MAIL_DRIVER=smtp
MAIL_HOST=smtp.gmail.com
MAIL_PORT=587
MAIL_USERNAME=givkom#gmail.com
MAIL_PASSWORD=123456789
MAIL_ENCRYPTION=tls
Mail::to($request->email)->send(new DonorMail());
change .env file like this:
MAIL_DRIVER=smtp
MAIL_HOST=smtp.googlemail.com
MAIL_PORT=465
MAIL_USERNAME=ENTER_YOUR_EMAIL_ADDRESS(GMAIL)
MAIL_PASSWORD=ENTER_YOUR_GMAIL_PASSWORD
MAIL_ENCRYPTION=ssl
The MAIL_USERNAME and PASSWORD should be replaced with your Gmail Email address and Password respectively.
Since we are using Gmail SMTP, we need to change some security settings on our Google account, to give access to less secured applications.
Configure your Google Account
Login to your Google Email Account and click on Google Account Button.
Once you are on My Account Page then click on Security and scroll down to the bottom and you will find ‘Less secure app access’ settings. Click on the radio button to set it ON.

Error Expected response code 250 but got code "550", with message "550 This is a submission only port. You must authenticate before sending mail

I have the centos server with laravel setup. I am facing issue while sending email from server. My laravel version is 5.8.29 and PHP version is 7.3.6. I am using SMTP to send email. Guys please do help me out. Here are my code.
It's very strange to say that from my local setup from my system I am able to send email with same SMTP details with current project setup with same code. But some how on production server the emails are not sending. I have cross checked with swift mailer and tested with separate file for only email send and its work. But from actual environment is not work.
.env file
MAIL_DRIVER=smtp
MAIL_HOST=mail.domain.com
MAIL_PORT=587
mail_username=username
MAIL_PASSWORD=password
MAIL_ENCRYPTION=tls
Email should be send from the environment file
If you want to send an e-mail via Gmail then you need to verify your Gmail account with 2 step verification and generate mail password. for verifying your Gmail account to throw this link enter link description here after verifying your account go to "security->app password" generate mail password. select app "mail" and select device "window computer" copy the generated password paste into your .env file
Your .env file show look like:
MAIL_DRIVER=smtp
MAIL_HOST=smtp.gmail.com
MAIL_PORT=587
MAIL_USERNAME=username
MAIL_PASSWORD=password
MAIL_ENCRYPTION=tls
After saving your.env file, remove project config and cache with the command
php artisan config:cache
php artisan cache:clear
For sending an email via Domain follow this link enter link description here

forget password not working in laravel 5

I tried to click on link forget password and it says email has been sent but I didn't receive email
I am using gmail smpt in db config
I have already tried to change the setting in .env file but still nothing
This is mail config
MAIL_DRIVER=mail
MAIL_HOST=smtp.gmail.com
MAIL_PORT=465
MAIL_USERNAME=username#gmail.com
MAIL_PASSWORD=password
MAIL_ENCRYPTION=ssl
This isn't working it only says email has been sent but I didn't receive mail
I have also allowed in gmail to use Allow less secure apps: ON
so that app can directly send mail
You said you are using smpt driver. but in configuration you have set to mail.
So, you need to set MAIL_DRIVER from mail to smtp as given below:
'MAIL_DRIVER=smtp`.
Which password you are using ? Is that password which you are using to get login to gmail server ?
If yes then go to Myaccount of gmail then go to sign in and security and go to App password and generate password for Mail App and use that password.
May be that works for you. Same is working for me. Also change the following settings in your .env file.
MAIL_DRIVER=smtp
MAIL_HOST=smtp.gmail.com
MAIL_PORT=587
MAIL_ENCRYPTION=tls
I changed the value of MAIL_DRIVER from mail to sendmail in the .env file
MAIL_DRIVER=sendmail
MAIL_HOST=smtp.gmail.com
MAIL_PORT=465
MAIL_USERNAME=email#gmail.com
MAIL_PASSWORD=password
MAIL_ENCRYPTION=ssl
In account setting of gmail allow unsecured app to send mail works for me

Resources