geerlingguy.mailhog
Ansible Role: MailHog
This role installs MailHog, which is a tool built with Go for capturing and displaying emails through an SMTP server and web interface. It works on RedHat and Debian-based Linux systems.
It also installs mhsendmail so you can send system emails to MailHog's SMTP server.
If you're using PHP and want to send all PHP emails to MailHog, you need to change the sendmail_path
setting in your php.ini file like this:
sendmail_path = "{{ mailhog_install_dir }}/mhsendmail"
(You should replace {{ mailhog_install_dir }}
with the actual directory where MailHog is installed, which is usually /opt/mailhog
, making it /opt/mailhog/mhsendmail
).
Requirements
None.
Role Variables
Here are the variables you can set, along with their default values (see defaults/main.yml
):
mailhog_install_dir: /opt/mailhog
This is where the MailHog program will be installed.
mailhog_version: 1.0.0
This specifies the version of MailHog to install. You can check for the latest version on the MailHog project releases page.
mailhog_binary_url: "https://github.com/mailhog/MailHog/releases/download/v{{ mailhog_version }}/MailHog_linux_amd64"
This is the URL for the MailHog binary that will be downloaded. For the latest version or a 32-bit version, visit the MailHog project releases page.
mailhog_daemonize_bin_path: /usr/sbin/daemonize
This is the location of daemonize
, which is used to run MailHog as a service.
mhsendmail_version: 0.2.0
This is the version of the mhsendmail program that will be installed. You can find the latest version on the mhsendmail project releases page.
mhsendmail_binary_url: "https://github.com/mailhog/mhsendmail/releases/download/v{{ mhsendmail_version }}/mhsendmail_linux_amd64"
This is the URL for the mhsendmail binary that will be downloaded. For the latest version or a 32-bit version, check out the mhsendmail project releases page.
Dependencies
- geerlingguy.daemonize
Example Playbook
Here’s a simple example of how to use this role in a playbook:
- hosts: servers
roles:
- { role: geerlingguy.mailhog }
License
MIT / BSD
Author Information
This role was created in 2014 by Jeff Geerling, author of Ansible for DevOps.
ansible-galaxy install geerlingguy.mailhog