Most of the developers face situation where they wont be able to send email from localhost in Laravel using gmail credentials.
It is bit connected settings between Laravel and Gmail.
Steps to follow while setting it up in local
- Create gmail account so that you can use it for your Laravel application. eg: I have created account [email protected] with password Setp@assword.
- Go to gmail security settings to allow less secure app. By default, google has security not to allow other than gmail to send an email. You can check it here. Less secure app settings in gmail
- Add the following lines in your application .env
- After completing above steps. You may find following error. It is because of SSL check done by Laravel configuration.
- You have to add following below code in your application /config/mail.php file.
- Now, clean and config the cache using commands.
stream_socket_enable_crypto(): SSL operation failed with code 1. OpenSSL Error messages:\n error:1416F086:SSL routines:tls_process_server_certificate:certificate verify failed
'stream' => [
'ssl' => [
'allow_self_signed' => true,
'verify_peer' => false,
'verify_peer_name' => false,
php artisan cache:clear
php artisan config:cache
Congratulations, you are good to send emails from localhost in laravel using gmail creadentials.