PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Saturday, April 9, 2022

[FIXED] Laravel Mail Connection could not be established Mailhog

 April 09, 2022     laravel, php     No comments   

Issue

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="hello@example.com"
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.


Solution

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


Answered By - Gev99
Answer Checked By - Gilberto Lyons (PHPFixing Admin)
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing