MailHog

MailHog is an email testing tool for developers. You can easily add it to your Lando app by adding an entry to the services key in your app's .lando.yml.

Prefer video tutorials?

Supported versions

Using patch versions

Because we use a third-party mailhog image specifying a patch version is not currently supported. If you need to use a patch version you might be able to use our advanced service config.

Example

# The name of the app
name: mailhog

# Start with the default LEMP recipe
recipe: lemp

# Additional mailhog proxy settings so we get a nice URL for the mailhog ui
proxy:
  mailhog:
    - mail.lemp.lndo.site

# Mailhog things
services:

  # Spin up a mailhog container called "mailhog"
  # NOTE: "mailhog" is arbitrary, you could just as well call this "blackhole" or "weezer"
  mailhog:

    # Use the latest mailhog version
    type: mailhog

    # List of services that we want to capture mail from
    # You can run `lando info` to get a list of services that are available
    # Mailhog expects that these services will be php services
    hogfrom:
      - appserver

    # Optionally allow access to the smtp service at localhost:1026
    # You will need to make sure port 1026 is open on your machine
    #
    # You can also set `portforward: true` to have Lando dynamically assign
    # an open port. Unlike specifying an actual port setting this to true will give you
    # a different port every time you restart your app
    portforward: 1026

# Access the mailhog send cli so we can easily tests things
tooling:
  sendmail:
    service: appserver
    cmd: /usr/local/bin/mhsendmail
  alert:
    service: appserver
    cmd: php /app/mail.php
    description: Tell Leia something important

You will need to rebuild your app with lando rebuild to apply the changes to this file. You can check out the full code for this example over here.

Getting information

You can get connection and credential information about your mailhog by running lando info from inside your app.

# Navigate to the app
cd /path/to/app

# Get info (app needs to be running to get this)
lando info

{
  "appserver": {
    "type": "php",
    "version": "7.1",
    "via": "nginx",
    "webroot": "."
  },
  "nginx": {
    "urls": [
      "https://localhost:33745",
      "http://localhost:33746",
      "http://mailhog.lndo.site",
      "https://mailhog.lndo.site"
    ]
  },
  "database": {
    "type": "mysql",
    "version": "latest",
    "creds": {
      "user": "lemp",
      "password": "lemp",
      "database": "lemp"
    },
    "internal_connection": {
      "host": "database",
      "port": 3306
    },
    "external_connection": {
      "host": "localhost",
      "port": true
    }
  },
  "mailhog": {
    "type": "mailhog",
    "version": "latest",
    "internal_connection": {
      "host": "mailhog",
      "port": 1025
    },
    "external_connection": {
      "host": "localhost",
      "port": 1026
    },
    "urls": [
      "http://localhost:33742",
      "http://admin.mailhog.lndo.site"
    ]
  }
}

results matching ""

    No results matching ""