Failed to send message from Laravel controller - laravel

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

Related

Laravel Mail Can't Send

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

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.

How to send email by gmail in Laravel

MAIL_DRIVER=smtp
MAIL_HOST=smtp.gmail.com
MAIL_PORT=587
MAIL_USERNAME=semhnh#gmail.com
MAIL_PASSWORD=********
MAIL_ENCRYPTION=tls
MAIL_FROM_ADDRESS=semhnh#gmail.com
MAIL_FROM_NAME="${APP_NAME}"
MY ERROR-->
Swift_TransportException
Expected response code 250 but got code "530", with message "530 5.7.1 Authentication required
how to send gmail email in larave, im very tired in this error, please help me
this is my .env file
my env file
this is may error image
email error
Gmail SMTP Settings
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
You must configure your Google Account
Login to your Google Email Account and click on Google Account Button.
This button is display when you click on the profile picture in your
Gmail Dashboard as shown.
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.
Complete reading here

How to send mail with laravel through gmail smtp?

I want to make contact Us page in my website, i have successfully do it with mailtrap, but when i want to send with gmail smtp server , i receive nothing and i get no error.
this is my .env mail config :
MAIL_DRIVER=smtp
MAIL_HOST=smtp.gmail.com
MAIL_PORT=465
MAIL_USERNAME=myemail
MAIL_PASSWORD=my_app_password
MAIL_ENCRYPTION=ssl
and code i use to send email:
$obj=new \stdClass();
$obj->contenu=$request->input('contenu');
$obj->objet=$request->input('objet');
$obj->email=$request->input('email');
$data=array('contenu'=>$obj->contenu,'email'=>$obj->email);
Mail::send("front.contactUs",$data,function ($message) use ($obj){
$message->from($obj->email);
$message->to('salondesbelleslettres#gmail.com')
->subject($obj->objet);
});
if(count(Mail::failures())>0){
return redirect()->back()->with('error','Votre demande na pas ete soumise');
}else{
return redirect()->back()->with('success','Merci de Nous Avoir Contacté');
}
Thanks.
Need to change your .env file to something like this:
MAIL_DRIVER=smtp
MAIL_HOST=smtp.gmail.com
MAIL_PORT=587
MAIL_USERNAME=myemail#gmail.com
MAIL_PASSWORD=apppassword
MAIL_ENCRYPTION=tls
After completion of .env edit please enter this command in your terminal for clear cache:
php artisan config:cache
You need to generate app password, and you can use that app password in .env file.
How to generate an App password:
Go to your Google Account
On the left navigation panel, click Security.
On the Signing in to Google panel, click App passwords.
(Note: If you can't get to the page, 2-Step Verification is:
Not set up for your account,
Set up for security keys only)
At the bottom, click Select app and choose the app you’re using.
Click Select device and choose the device you’re using.
Click Generate
Follow the instructions to enter the App password (the 16 character code in the yellow bar) on your device.
Click Done.
Once you are finished, you won’t see that App password code again.
Note: You may not be able to create an App password for less secure apps.
These settings worked for me instead.
MAIL_DRIVER=smtp
MAIL_HOST=smtp.gmail.com
MAIL_PORT=587
MAIL_USERNAME=myemail#gmail.com
MAIL_PASSWORD=mypassword
MAIL_ENCRYPTION=tls
You should try this:
MAIL_DRIVER=smtp
MAIL_HOST=smtp.gmail.com
MAIL_PORT=587
MAIL_USERNAME=youremailaddress#gmail.com
MAIL_PASSWORD=gtxajikwsqmlaqcr // your app password
MAIL_ENCRYPTION=tls

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