5

I'm getting an error in mailhog while sending an email.

Error:

Connection could not be established with host mailhog :stream_socket_client(): unable to connect to null://mailhog:1025 (Unable to find the socket transport "null" - did you forget to enable it when you configured PHP?)

my code :

Mail::to('sample@example.com')->send(new MessageMail($message));

and .env config:

MAIL_MAILER=smtp
MAIL_HOST=mailhog
MAIL_PORT=1025
MAIL_USERNAME=
MAIL_PASSWORD=
MAIL_ENCRYPTION=null
MAIL_FROM_ADDRESS=info@site.com
MAIL_FROM_NAME="${APP_NAME}"

I use docker and my laravel version is 8, PHP Version 7.4.10 as well I am migrating from symfony to laravel.

Martin Shahbazi
  • 53
  • 1
  • 1
  • 6

2 Answers2

6

As stated by Ken Lee in the comments:

You're using an invalid value (null) for MAIL_ENCRYPTION.

MAIL_ENCRYPTION=null

Use an empty value instead for MAIL_ENCRYPTION:

MAIL_ENCRYPTION=
Nicolai Fröhlich
  • 51,330
  • 11
  • 126
  • 130
0

Close The Serve than Run:

php artisan optimize:clear

and still you facing this issue close the project and Run it again. I hope it's Work and you don't need to do any changing in .env

MAIL_ENCRYPTION=tls
Scync Tech
  • 11
  • 1
  • Please add some explanation to your answer such that others can learn from it. There's an accepted answer on this question, which means that the OP could resolve the problem with the details given there. What makes you think that a completely different answer works in the same way? – Nico Haase Feb 15 '23 at 13:11
  • 1
    As it’s currently written, your answer is unclear. Please [edit] to add additional details that will help others understand how this addresses the question asked. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community Feb 20 '23 at 06:28