1

I want to sent mails from my laravel project with gmail smtp from localhost.

this is my .env file

MAIL_DRIVER=smtp    
MAIL_HOST=smtp.gmail.com   
MAIL_PORT=587      
MAIL_USERNAME=myemail@gmail.com
MAIL_PASSWORD=password
MAIL_ENCRYPTION=tls

This is my config/mail.php file

    'driver' => env('MAIL_DRIVER', 'smtp'),
    'host' => env('MAIL_HOST', 'smtp.gmail.com'),
    'port' => env('MAIL_PORT', 587),
    'from' => [
        'address' => env('MAIL_FROM_ADDRESS', 'myemail@gmail.com'),
        'name' => env('MAIL_FROM_NAME', 'My Name'),
    ],
    'encryption' => env('MAIL_ENCRYPTION', 'tls'),

    'username' => env('myemail@gmail.com'),

    'password' => env('password'),

When I run the script, it gives me the following error:

ErrorException in StreamBuffer.php line 94:
stream_socket_enable_crypto(): SSL operation failed with code 1. OpenSSL Error messages:
error:14090086:SSL routines:ssl3_get_server_certificate:certificate verify failed

Please note that I have already enabled the extension in my php.ini file.

Ajmal Razeel
  • 1,663
  • 7
  • 27
  • 51
  • seems that you dont have ssl cert installed on your local server. you can just use `aspmx.l.google.com` as host and port 25 with no encryption. tho mail can only be sent to Gmail or G Suite users. but i think its fine since youre in dev env yet. see more details [here](https://support.google.com/a/answer/176600?hl=en). – elegisandi Jul 31 '17 at 07:02

3 Answers3

1

your .env looks clean, but you need to double check if you change the account access for less secure apps.

Go to the Less secure apps section then set to active.

Hope this work for you !!!

AddWeb Solution Pvt Ltd
  • 21,025
  • 5
  • 26
  • 57
0

just remove MAIL_ENCRYPTION=tls from the .env file

and in your mail.php comment the following code line:

'encryption' => env('MAIL_ENCRYPTION', 'tls'), //comment this line

Hope that solves your problem.

Sagar Arora
  • 1,743
  • 1
  • 10
  • 19
-2

In your env just use:

MAIL_DRIVER=sendmail

Andres R
  • 40
  • 1
  • 4