Mailhog is a tool to test the you application mail outgoing.
Steps to use with docker
First, install mailhog sendmail tool in your php docker container
wget https://github.com/mailhog/mhsendmail/releases/download/v0.2.0/mhsendmail_linux_amd64 sudo chmod +x mhsendmail_linux_amd64 sudo mv mhsendmail_linux_amd64 /usr/local/bin/mhsendmail
Second, change your php.ini sendmail_path value as follows
sendmail_path = '/usr/local/bin/mhsendmail --smtp-addr="mailhog-cont:1025"'
Third, add mailhog in your docker compose file
mailhog-cont: container_name: pvh-mailhog image: mailhog/mailhog networks: magento23_app_net: ipv4_address: 10.0.0.25
Final, test the mail in php script or with your application after restaring fpm
sudo service php7.4-fpm restart
php -r "\$from = \$to = 'firstname.lastname@example.org'; \$x = mail(\$to, 'testing from php cli', 'Hello World', 'From: '. \$from); var_dump(\$x);"
You can view the message as api request or with web interface