skip to Main Content

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('[email protected]')->send(new MessageMail($message));

and .env config:

MAIL_MAILER=smtp
MAIL_HOST=mailhog
MAIL_PORT=1025
MAIL_USERNAME=
MAIL_PASSWORD=
MAIL_ENCRYPTION=null
[email protected]
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.

2

Answers


  1. 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=
    
    Login or Signup to reply.
  2. 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
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search