Mailpit is a small, fast, low memory, zero-dependency, multi-platform email testing tool & API for developers.
It acts as an SMTP server, provides a modern web interface to view & test captured emails, and contains an API for automated integration testing
See https://mailpit.axllent.org/
It receives and stores the mails (temporarily) local and gives you a web interface to access them.
Install using homebrew:
brew install mailpitStart the Mailpit service:
brew services start mailpitGo to the web based interface http://127.0.0.1:8025.
We will force PHP to send out email trough sendmail. But just to be sure we will set Mailpit as the relayhost of postfix:
sudo vi /etc/postfix/main.cfAdd following line at the end of the config file:
relayhost = 127.0.0.1:1025
Every PHP version needs to be updated so email are send locally to MailHog instead of to real users:
sed -e 's/;*sendmail_path =.*/sendmail_path = \/opt\/homebrew\/bin\/mailpit sendmail test@test/' -i.bak $(brew --prefix)/etc/php/[VERSION]/php.iniNote : Run the command multiple times and replace [VERSION] by the different installed PHP versions (8.4, 8.5, ...).
Restart PHP to activate configuration changes
sphp 8.5