Home > Enterprise >  Laravel Mail Connection could not be established Mailhog
Laravel Mail Connection could not be established Mailhog

Time:04-10

I've installed Laravel Breeze and the 'forgot password' functionallity does not work. Login and registrer both work well, so I guess there is something wrong at sending the recovery email.

This is the displayed error:

"Connection could not be established with host "mailhog:1025": stream_socket_client(): php_network_getaddresses: getaddrinfo failed: Temporary failure in name resolution"

at Symfony \ Component \ Mailer \ Exception \ TransportException.

and here is an screenshot: error

This is part of my .env file:

MAIL_MAILER=smtp
MAIL_HOST=mailhog
MAIL_PORT=1025
MAIL_USERNAME=null
MAIL_PASSWORD=null
MAIL_ENCRYPTION=null
MAIL_FROM_ADDRESS="[email protected]"
MAIL_FROM_NAME="${APP_NAME}"

The environment is:

  • Ubuntu 21.10
  • Laravel 9.7.0
  • PHP 8.0.8

Tested via php artisan serve

This is a new Laravel project in which I only installed Laravel Breeze for login handling. Laravel Sail is installed.

CodePudding user response:

you need to add this 127.0.0.1 mailhog in your hosts file and change this MAIL_HOST=0.0.0.0 in .env file or use MAIL_HOST=localhost

also you can check if your mailhog is enabled

sudo service mailhog status

To enable:

sudo systemctl enable mailhog 

To start:

sudo systemctl start mailhog
  • Related