-1

I'm new to Laravel; I'm trying to send reset password email with Mailtrap, bun when I try it, I got this error:

Connection could not be established with host "ssl://sandbox.smtp.mailtrap.io:465": stream_socket_client(): SSL operation failed with code 1. OpenSSL Error messages: error:0A00010B:SSL routines::wrong version number

this is my .env file:

MAIL_MAILER=smtp
MAIL_HOST=sandbox.smtp.mailtrap.io
MAIL_PORT=465
MAIL_USERNAME=454d94****52fa
MAIL_PASSWORD=991eae****e5b5
MAIL_ENCRYPTION=tls
MAIL_FROM_ADDRESS="hello@example.com"
MAIL_FROM_NAME="${APP_NAME}"
  • I received a new username and password from Mailtrap
  • I tried with all 4 available ports
  • I logged in with another google account to mailtrap and try it with new username and password

I tried all these things but still got this error

3 Answers3

0

I was able to solve the problem after two days!
The problem was from Mailtrap
Once I installed the mailpit package on localhost, I was able to receive the recovery email easily

0

short answer:

use MAIL_ENCRYPTION=starttls when using sandbox.smtp.mailtrap.io on port 465

long answer: Port 465 on SMTP is normally SMTP over TLS which means MAIL_ENCRYPTION should be set to tls.

However, if you run

openssl s_client sandbox.smtp.mailtrap.io:465

you can tell that this is not how Mailtrap has configured this port. It's configured to run plain SMTP which you can upgrade to an encrypted connection using the STARTTLS command.

I believe this full config should work for you:

MAIL_MAILER=smtp
MAIL_HOST=sandbox.smtp.mailtrap.io
MAIL_PORT=465
MAIL_USERNAME=454d94****52fa
MAIL_PASSWORD=991eae****e5b5
MAIL_ENCRYPTION=starttls
MAIL_FROM_ADDRESS="hello@example.com"
MAIL_FROM_NAME="${APP_NAME}"

Disclosure: I work for Mailosaur, a similar service as Mailtrap.

AndyD
  • 5,252
  • 35
  • 32
-1

Follow these steps:

  1. Check your user password is correct
  2. Check your mail provider has not closed your account
  3. Remove the cache (config and everything) php artisan optimize:clear
  4. Try and check these mail ports one by one (25 or 465 or 587 or 2525)
AHSEN ALEE
  • 29
  • 5
  • I had done all these steps even received a new username and password from Mailtrap and tried with all 4 available ports But I still got the same error – mahdi_sheykh Jul 06 '23 at 09:28
  • Check PHP configuration: Verify that the OpenSSL extension is enabled in your PHP configuration. You can do this by checking the `php.ini` file and ensuring that the line extension=openssl is not commented out. If still not work remove `sandbox.` from MAIL_HOST – AHSEN ALEE Jul 06 '23 at 09:34
  • I did both but still get that error! – mahdi_sheykh Jul 08 '23 at 07:52