Reputation: 51
Connection could not be established with host smtp.gmail.com :stream_socket_client(): unable to connect to ssl://smtp.gmail.com:465 (Connection refused)
I tried to send email using laravel but i could not able to send email using godaddy Shared Hosting.
MAIL_DRIVER=smtp
MAIL_HOST=smtp.gmail.com
MAIL_PORT=465
MAIL_ENCRYPTION=ssl
Upvotes: 4
Views: 16510
Reputation: 1
It is because you did not check your email account config you must go to c panel and email section and front of your email choose connect devices and check your out putting server you write wrong information on .env You must add this information
Upvotes: -1
Reputation: 1
I think you should surround them with "", I don't know why but it worked to my case.
MAIL_DRIVER="smtp"
MAIL_HOST="smtp.gmail.com"
MAIL_PORT="465"
MAIL_ENCRYPTION="ssl"
Upvotes: 0
Reputation: 21
I have the same issue during development in localhost. I would wanted to test sending of emails from my application using laravel SMTP mailer. Finally the solution was that I added verify_peer and verify_peer_name fields with the value false to SMPTconfig 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)
]
]
Upvotes: 0
Reputation: 63
Try this:
MAIL_DRIVER=smtp
MAIL_HOST=smtp.gmail.com
MAIL_PORT=587
MAIL_ENCRYPTION=
Or better:
MAIL_DRIVER=smtp
MAIL_HOST=smtp.gmail.com
MAIL_PORT=587
[email protected]
MAIL_PASSWORD=secret
MAIL_ENCRYPTION=tls
Upvotes: 4