The majority of tools are installed via the Homebrew tool. We will refer the Homebrew root directory with <HOMEBREW_[package]>, which can be retrieved via the command
brew --prefix [package]
Sendmail redirects mail to MailHog using SMTP
.
For PHP projects, you need to connect all locally installed versions of PHP to MailHog and setup to use it.
Replace
<PHP_VERSION>
by your version[7.3|7.4|<MAJOR.MINOR>]
- For each PHP version, create the configuration file
<HOMEBREW_[php@VERSION]>/conf.d/z-mailhog.ini
and replace all content by:
sendmail_path = "/usr/local/bin/mailhog sendmail [email protected]"
- Then restart all PHP server
MailHog runs on the localhost and listens on the SMTP port 1025
and HTTP port 8025
.
You can configure a Server Block with a NGINX reverse proxy to forward port 8025
.
To configure a Server Block
(like "VirtualHost" Apache term), please make sure that NGINX is installed.
Otherwise, follow the instructions at Documentation > Installation > NGINX
The default directory location of the Server Block
is <HOMEBREW_[nginx]>/servers/
.
Create a directory:
mkdir -p $(brew --prefix nginx)/servers/mailhog.test
Create the configuration file <HOMEBREW_[nginx]>/servers/mailhog.test/mailhog.conf
and replace all content by:
server {
listen 80;
server_name mailhog.test;
charset utf-8;
client_max_body_size 128M;
location / {
chunked_transfer_encoding on;
proxy_set_header X-NginX-Proxy true;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
proxy_http_version 1.1;
proxy_redirect off;
proxy_buffering off;
proxy_pass http://localhost:8025;
}
}
Before starting MailHog, ensure that NGINX server is restarted.
To access the web interface, enter : http://mailhog.test
or http://localhost:8025
in your browser.
You can either use the native command or the
Pleaz
CLI.
- Start service:
## Native
sudo brew services start mailhog
## Pleaz CLI
pleaz service:start mailhog
- Stop service:
## Native
sudo brew services stop mailhog
## Pleaz CLI
pleaz service:stop mailhog
- Restart service:
## Native
brew services restart mailhog
## Pleaz CLI
pleaz service:restart mailhog