How to Test Outbound Email Functionality in Your Local Drupal Development Environment?

| | 2 min read

Testing email functionality in Drupal is a common use case every developer encounters frequently. Setup a full-featured email system locally or using a 3rd party service for just testing emails may not be feasible always.

Mailhog is the best solution available for this scenario and the bonus point is that it works perfectly with Lando.

The general idea of Mailhog is that it acts as a local SMTP server that by default, doesn't send emails to the addressed recipients. Rather, it includes a clean UI that allows the developer to view outgoing emails. 


  • To use mailhog you have to install and configure SMTP module
  • Your lando should be configured to use mailhog as a service. Please check lando.yml and make sure that the service is available.
name: drupal
recipe: drupal9
    webroot: web
      type: mailhog
  • Once you start lando, check lando info for host and port information of 'mail' service of type 'mailhog'.
$lando info

{ service: 'mail',
    urls: [ 'http://localhost:49157' ],
    type: 'mailhog',
    healthy: true,
    hogfrom: [],
    internal_connection: { host: 'mail', port: '1025' },
    external_connection: { host: '', port: 'not forwarded' },
    config: {},
    version: 'v1.0.1',
    meUser: 'mailhog',
    hasCerts: false,
    hostnames: [ 'mail.debug.internal' ] } ]
  • Set up these host as SMTP server and port as SMTP port in the SMTP module configuration.
SMTP Authentication Support.png
  • Open the url for mailhog ( You can get that in lando info) for the interface to see the emails sent from your site.

Please note that the emails will be available in mailhog only for 24 hours by default.