2014-12-17 19:54:29 +00:00
|
|
|
Configuring MailHog
|
|
|
|
===================
|
|
|
|
|
2014-12-24 17:57:47 +00:00
|
|
|
You can configure MailHog using command line options or environment variables:
|
2014-12-17 19:54:29 +00:00
|
|
|
|
2014-12-24 19:25:02 +00:00
|
|
|
| Environment | Command line | Default | Description
|
|
|
|
| ------------------- | --------------- | --------------- | -----------
|
2020-09-14 18:15:30 +00:00
|
|
|
| MH_CORS_ORIGIN | -cors-origin | | If set, an Access-Control-Allow-Origin header is returned for API endpoints
|
2014-12-24 19:25:02 +00:00
|
|
|
| MH_HOSTNAME | -hostname | mailhog.example | Hostname to use for EHLO/HELO and message IDs
|
2016-03-14 16:29:44 +00:00
|
|
|
| MH_API_BIND_ADDR | -api-bind-addr | 0.0.0.0:8025 | Interface and port for HTTP API server to bind to
|
|
|
|
| MH_UI_BIND_ADDR | -ui-bind-addr | 0.0.0.0:8025 | Interface and port for HTTP UI server to bind to
|
2016-03-20 17:19:28 +00:00
|
|
|
| MH_MAILDIR_PATH | -maildir-path | | Maildir path (for maildir storage backend)
|
2014-12-24 19:25:02 +00:00
|
|
|
| MH_MONGO_COLLECTION | -mongo-coll | messages | MongoDB collection name for message storage
|
|
|
|
| MH_MONGO_DB | -mongo-db | mailhog | MongoDB database name for message storage
|
|
|
|
| MH_MONGO_URI | -mongo-uri | 127.0.0.1:27017 | MongoDB host and port
|
|
|
|
| MH_SMTP_BIND_ADDR | -smtp-bind-addr | 0.0.0.0:1025 | Interface and port for SMTP server to bind to
|
2016-03-20 17:19:28 +00:00
|
|
|
| MH_STORAGE | -storage | memory | Set message storage: memory / mongodb / maildir
|
2015-02-24 21:49:42 +00:00
|
|
|
| MH_OUTGOING_SMTP | -outgoing-smtp | | JSON file defining outgoing SMTP servers
|
2020-09-14 18:15:30 +00:00
|
|
|
| MH_UI_WEB_PATH | -ui-web-path | | WebPath under which the UI is served (without leading or trailing slashes), e.g. 'mailhog'
|
2017-11-28 17:02:28 +00:00
|
|
|
| MH_AUTH_FILE | -auth-file | | A username:bcryptpw mapping file
|
2014-12-24 19:25:02 +00:00
|
|
|
|
|
|
|
#### Note on HTTP bind addresses
|
|
|
|
|
|
|
|
If `api-bind-addr` and `ui-bind-addr` are identical, a single listener will
|
|
|
|
be used allowing both to co-exist on one port.
|
|
|
|
|
|
|
|
The values must match in a string comparison. Resolving to the same host and
|
|
|
|
port combination isn't enough.
|
2015-02-24 21:49:42 +00:00
|
|
|
|
|
|
|
### Outgoing SMTP configuration
|
|
|
|
|
|
|
|
Outgoing SMTP servers can be set in web UI when releasing a message, and can
|
|
|
|
be temporarily persisted for later use in the same session.
|
|
|
|
|
|
|
|
To make outgoing SMTP servers permanently available, create a JSON file with
|
|
|
|
the following structure, and set `MH_OUTGOING_SMTP` or `-outgoing-smtp`.
|
|
|
|
|
|
|
|
```json
|
|
|
|
{
|
|
|
|
"server name": {
|
|
|
|
"name": "server name",
|
|
|
|
"host": "...",
|
2015-04-06 10:50:34 +00:00
|
|
|
"port": "587",
|
2015-02-24 21:49:42 +00:00
|
|
|
"email": "...",
|
|
|
|
"username": "...",
|
|
|
|
"password": "...",
|
2015-04-06 10:48:55 +00:00
|
|
|
"mechanism": "PLAIN"
|
2015-02-24 21:49:42 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
```
|
|
|
|
|
|
|
|
Only `name`, `host` and `port` are required.
|
|
|
|
|
|
|
|
`mechanism` can be `PLAIN` or `CRAM-MD5`.
|
2016-11-14 22:58:27 +00:00
|
|
|
|
|
|
|
### Firewalls and proxies
|
|
|
|
|
2018-08-28 03:01:48 +00:00
|
|
|
If you have MailHog behind a firewall, you'll need ports `8025` and `1025` by default.
|
2016-11-14 22:58:27 +00:00
|
|
|
|
2018-03-12 11:44:14 +00:00
|
|
|
You can override this using `-api-bind-addr`, `-ui-bind-addr` and `-smtp-bind-addr` configuration options.
|
2016-11-14 22:58:27 +00:00
|
|
|
|
|
|
|
If you're using MailHog behind a reverse proxy, e.g. nginx, make sure WebSocket connections
|
|
|
|
are also supported and configured - see [this issue](https://github.com/mailhog/MailHog/issues/117) for information.
|