Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

viktor3177's avatar

Laravel9 - Error when sending mail (Expected response code "250" but got an empty response.).

I created a temporary mail in (Google Workspace) and connected everything to the test site, but when sending an email from the site I get an error (Expected response code "250" but got an empty response.)

Here is the code from file .env

MAIL_MAILER=smtp
MAIL_HOST=smtp-relay.gmail.com
MAIL_PORT=465
[email protected]
MAIL_PASSWORD=password
MAIL_ENCRYPTION=tls
MAIL_FROM_ADDRESS="[email protected]"
MAIL_FROM_NAME="${APP_NAME}"

And here is the controller

$email_admin = "[email protected]";
    $to_name = 'Reservation';

    $to_email = '[email protected]';
    $to_client_email = $request->email;

    Mail::send('mail', compact('reservations'), function ($message) use ($reservations, $to_email) {
        $message->from("[email protected]", 'username');
        $message->to($to_email)->subject('laravel reservation');

    });

    $repsond=Mail::send('mail_client', compact('reservations'), function ($message) use ($reservations, $to_client_email) {
        $message->from("[email protected]", 'username');
        $message->to($to_client_email)->subject('laravel reservation client');
    });
0 likes
13 replies
vincent15000's avatar

Have you authorized your google account to be accessed from a third party in the google account configuration ?

viktor3177's avatar

@vincent15000

It?

Allow per-user outbound gateways Allow users to send mail through an external SMTP server when configuring a "from" address hosted outside your email domain: ON

1 like
viktor3177's avatar

@vincent15000

Looked and tried everything that was written there, but it did not help. I also contacted Google technical support today, there are no problems on their part. So there is a problem with the site. And I understand that in the controller, although before I changed the MX there were no problems when sending.

1 like
viktor3177's avatar

@vincent15000

Today, when I contacted Google technical support, they checked them through the screen and said that everything is OK here.

1 like
vincent15000's avatar

@viktor3177 To access to google email features (smtp, ...) from a third party (your app), Google doesn't let you choose your password, but generates a random serie of 16 letters as equivalent to your password.

Are you sure you have activated your Google account to access it from your app ?

mskorok's avatar

this solved problem for me: php artisan queue:work --sleep=3 --tries=3 --delay=30

sof questions/60490001/swift-transportexception-expected-response-code-250-but-got-an-empty-response-i

Please or to participate in this conversation.