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

Nrt's avatar

I have the same issue during development in localhost. I had would like to test sending of email from my application used laravel smtp mailer. Finally the solution was that I added verify_peer and verify_peer_name fields with value false to smpt config in config/mail.php.


'mailers' => [
        'smtp' => [
            'transport' => 'smtp',
            'host' => env('MAIL_HOST', 'smtp.gmail.com'),
            'port' => env('MAIL_PORT', 465),
            'encryption' => env('MAIL_ENCRYPTION', 'ssl'),
            'username' => env('MAIL_USERNAME'),
            'password' => env('MAIL_PASSWORD'),
            'timeout' => null,
            'local_domain' => env('MAIL_EHLO_DOMAIN'),
            'verify_peer' => env('MAIL_VALIDATE_CERT',  false),
            'verify_peer_name' => env('MAIL_VALIDATE_CERT',  false)
        ]
]
liviu_iurcu's avatar

.env file localhost server

MAIL_DRIVER=smtp MAIL_HOST=smtp.gmail.com MAIL_PORT=587 [email protected] MAIL_PASSWORD=********* MAIL_ENCRYPTION=tls MAIL_FROM_ADDRESS="[email protected]" MAIL_FROM_NAME="${APP_NAME}"

Live server

MAIL_DRIVER=sendmail MAIL_HOST=smtp.gmail.com MAIL_PORT=587 [email protected] MAIL_PASSWORD=********* MAIL_ENCRYPTION=tls MAIL_FROM_ADDRESS="[email protected]" MAIL_FROM_NAME="${APP_NAME}" And also replace MAIL_MAILER=sendmail in mail.php file.

#config/mail.php

#old code 'default' => env('MAIL_MAILER', 'smtp'),

#new code 'default' => env('MAIL_MAILER', 'sendmail'),

dangeamro's avatar

Just change as bellow and It will work on server. MAIL_MAILER=smtp >>> MAIL_MAILER=sendmail

1 like
dipeshkhanal79's avatar

IF anyone is still search for the fix then this might be useful for you. @moses says he is using cPanel and the cPanel might have blocked SMTP. So you need to disable the SMTP restriction on your cPanel. You can contact your cPanel Provider to do so.

Previous

Please or to participate in this conversation.