I'm trying to send Emails from google but couln't make it yet. I did everything I've found by searching through google but it still won't work.
My Mail.php
'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', 'blablabla'),
],
'encryption' => env('MAIL_ENCRYPTION', 'tls'),
'username' => env('MAIL_USERNAME'),
'password' => env('MAIL_PASSWORD'),
'sendmail' => '/usr/sbin/sendmail -bs',
my .env:
MAIL_DRIVER=smtp
MAIL_HOST=smtp.gmail.com
MAIL_PORT=587
MAIL_USERNAME=myemail@gmail.com
MAIL_PASSWORD=mypassword
MAIL_ENCRYPTION=tls
I also allowed "Less secure Apps" on the gmail settings.
The Mail-Code works perfect, I've tried it out before on mailtrap.io. But if I change it to google I only get errors.
Thats my Code for sending Mail:
\Mail::to('hardcodededmail@gmail.com')->send(new NewThread($thread));
And thats the error:
(1/1) ErrorException
stream_socket_enable_crypto(): SSL operation failed with code 1. OpenSSL Error messages:
error:14090086:SSL routines:ssl3_get_server_certificate:certificate verify failed
Can someone help me there?
Try this, it works for me:
MAIL_PORT=465
MAIL_ENCRYPTION="ssl"
Also make sure to generate an app password if you're using 2FA.
Don't use TLS or SSL then.
MAIL_ENCRYPTION=tls
'encryption' => env('MAIL_ENCRYPTION', 'tls'),
Change both to:
MAIL_ENCRYPTION=
'encryption' => env('MAIL_ENCRYPTION', ''),
Then run:
php artisan config:clear
This should do the job
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.