Try this,
MAIL_DRIVER=smtp
MAIL_HOST=smtp.googlemail.com
MAIL_PORT=587
MAIL_USERNAME=sanjiarya2112@gmail.com
MAIL_PASSWORD=mypassword
MAIL_ENCRYPTION=tls
This works to me.
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
Hi Awesome People
I'm trying to send email in my application, but i'm getting the following error
Swift_TransportException in StreamBuffer.php line 269:
Connection could not be established with host smtp.gmail.com [A connection attempt failed because the
connected party did not properly respond after a period of time, or established connection failed because
connected host has failed to respond. #10060]
My configration in ".env" is as follows
MAIL_DRIVER=smtp
MAIL_HOST=smtp.gmail.com
MAIL_PORT=587
MAIL_USERNAME=sanjiarya2112@gmail.com
MAIL_PASSWORD=mypassword
MAIL_ENCRYPTION=null
And My Controller is "AvoContactController.php"
<?php
namespace App\Http\Controllers;
use View;
Use Mail;
use App\AvoContact;
use App\Http\Requests;
use App\Http\Requests\ContactFormRequest;
use Illuminate\Routing\Controller as BaseController;
class AvoContactController extends BaseController {
public function contactpage()
{
$contact = AvoContact::all();
return view('pages.contact')->with(['contact' => $contact]);
}
public function store(ContactFormRequest $request)
{
Mail::send('emails.contact', [], function ($m) use($request){
$m
->from($request->get('email'))
->to('sanjiarya2112@gmail.com')
->subject('Your Reminder!');
});
return 'Email Sent';
}
}
I did tried installing "guzzle" But it din't help i'm still getting the same error
Looking forward for much needed help @bashy @bobbybouwmann @pmall @mstnorris @willvincent @snapey
Thank You
@MrRobot21 you have to use the app key.
The mechanism is an extra layer of security Google adds.
If you still get the same error, again, regenerate a new app key, logout out from your account (sanjiarya2112@gmail.com) and try to send mail again via your app.
Please or to participate in this conversation.