Greetings to the community!
I have recently developed a web page with Laravel 9.X, which works correctly in local, but when I upload it to my Host, I am having problems with sending emails.
When I have been testing locally, it has been working correctly, and I have been using mailtrap. Now that I have uploaded it to the server, I have my own SMTP, and it is not working for me. I have the ssl certificate created, but there is no way it will send me any mail. I get the following error:
Unable to connect with STARTTLS: stream_socket_enable_crypto(): SSL operation failed with code 1. OpenSSL Error messages: error:14090086:SSL routines:ssl3_get_server_certificate:certificate verify failed.
SSL working fine when i visit the site with https.
I have configured my .env
file, where I have put:
HOST
: my smtp server; PORT
: 587; ENCRYPTION TYPE
: SSL; USERNAME AND PASSWORD
: Those of my email account.
I have been touching also my file located in config/mail.php
, putting the same configuration as in the .env
file. I have also tried with other ports like 25, 465... among others.
I have tried to access the mail account from outlook, using the IMAP
protocol, and I have been able to connect correctly, so the mail can be accessed.
I have checked lot of things in Google, and also every blogs y found in Stack Overflow, but nothing worked.
Any idea what is going on? Am I missing something to configure?
I had this problem after upgrading to the new 9 version, so you need to follow two steps.
Edit your .env
file located in the root of the project The place where your mail settings are described, change tls
to null
. If you do not have such a line, then add
MAIL_ENCRYPTION=null
If you have version 8 then this will be enough, but in version Laravel 9 you will need to open the file app/config/mail.php
Find a section mailers smtp
add two options 'auth_mode' => null
and 'verify_peer' => false
an example of how it would look
'mailers' => [
'smtp' => [
'transport' => 'smtp',
'host' => env('MAIL_HOST', 'smtp.mailgun.org'),
'port' => env('MAIL_PORT', 587),
'encryption' => env('MAIL_ENCRYPTION', 'tls'),
'username' => env('MAIL_USERNAME'),
'password' => env('MAIL_PASSWORD'),
'timeout' => null,
'auth_mode' => null,
'verify_peer' => false,
],