Bobcares

Docker Mailhog Sendmail | Set Up Guide

by | Feb 29, 2024

Learn how to set up Docker Mailhog & Sendmail. Our Sendmail Support team is here to help you with your questions and concerns.

Docker Mailhog Sendmail | Set Up Guide

MailHog is a popular open-source email testing tool. It lets developers test the web app’s email-sending and receiving features more efficiently.

In this blog post, we will take a close look at setting up Docker MailHog and Sendmail.

Docker Mailhog Sendmail | Set Up Guide

The process usually involves running MailHog and a Sendmail-compatible service inside Docker containers. This setup lets developers test email functionality within their applications and not worry about emails being sent to real recipients.

How to Set Up Docker MailHog and Sendmail

  1. To begin with, make sure Docker is installed on the system.
  2. Then, we have to create a `docker-compose.yml` file in our project directory with the following content to set up MailHog and a Sendmail-compatible service.

    version: '3'
    services:
    mailhog:
    image: mailhog/mailhog
    ports:
    - "1025:1025" # SMTP port
    - "8025:8025" # MailHog web UI port
    sendmail:
    image: mailhog/sendmail
    environment:
    RELAY_HOST: mailhog:1025 # MailHog SMTP host and port

  3. Now, head to the directory with the `docker-compose.yml` file in a terminal and run the following command to start the Docker containers:

    docker-compose up -d

    This command pulls the required Docker images and starts the MailHog and Sendmail containers in detached mode.

  4. Next, update the application’s email configuration to use the Sendmail service. Typically, set the SMTP server to `localhost` and the port to `25`.
  5. Then, start the application and trigger any functionality that sends emails. MailHog intercepts these emails, and we can view them through the MailHog web UI at http://localhost:8025.
  6. Now, open the MailHog web UI to inspect intercepted emails, including content, headers, and recipients.
  7. After testing, stop the Docker containers with the following command:

    docker-compose down

Configure MailHog with mhsendmail

For more control over email routing, we can use `mhsendmail`. It is a sendmail replacement tailored for MailHog. Follow these steps to configure and use `mhsendmail`:

  1. To begin with, download `mhsendmail` from its GitHub repository.
  2. Then, edit the web app’s configuration to use `mhsendmail` as the email routing service. Most systems default to `sendmail`, so adjust the `sendmail_path` in the `php.ini` file.
    • For Linux systems, set the value to:

      sendmail_path = /usr/local/bin/mhsendmail

    • For Mac users, edit the Postfix config file with:

      myhostname = localhost
      relayhost = [127.0.0.1]:1025

[Need assistance with a different issue? Our team is available 24/7.]

Conclusion

In brief, our Support Experts demonstrated how to set up Docker Mailhog & Sendmail.

PREVENT YOUR SERVER FROM CRASHING!

Never again lose customers to poor server speed! Let us help you.

Our server experts will monitor & maintain your server 24/7 so that it remains lightning fast and secure.

GET STARTED

0 Comments

Submit a Comment

Your email address will not be published. Required fields are marked *

Never again lose customers to poor
server speed! Let us help you.

Privacy Preference Center

Necessary

Necessary cookies help make a website usable by enabling basic functions like page navigation and access to secure areas of the website. The website cannot function properly without these cookies.

PHPSESSID - Preserves user session state across page requests.

gdpr[consent_types] - Used to store user consents.

gdpr[allowed_cookies] - Used to store user allowed cookies.

PHPSESSID, gdpr[consent_types], gdpr[allowed_cookies]
PHPSESSID
WHMCSpKDlPzh2chML

Statistics

Statistic cookies help website owners to understand how visitors interact with websites by collecting and reporting information anonymously.

_ga - Preserves user session state across page requests.

_gat - Used by Google Analytics to throttle request rate

_gid - Registers a unique ID that is used to generate statistical data on how you use the website.

smartlookCookie - Used to collect user device and location information of the site visitors to improve the websites User Experience.

_ga, _gat, _gid
_ga, _gat, _gid
smartlookCookie
_clck, _clsk, CLID, ANONCHK, MR, MUID, SM

Marketing

Marketing cookies are used to track visitors across websites. The intention is to display ads that are relevant and engaging for the individual user and thereby more valuable for publishers and third party advertisers.

IDE - Used by Google DoubleClick to register and report the website user's actions after viewing or clicking one of the advertiser's ads with the purpose of measuring the efficacy of an ad and to present targeted ads to the user.

test_cookie - Used to check if the user's browser supports cookies.

1P_JAR - Google cookie. These cookies are used to collect website statistics and track conversion rates.

NID - Registers a unique ID that identifies a returning user's device. The ID is used for serving ads that are most relevant to the user.

DV - Google ad personalisation

_reb2bgeo - The visitor's geographical location

_reb2bloaded - Whether or not the script loaded for the visitor

_reb2bref - The referring URL for the visit

_reb2bsessionID - The visitor's RB2B session ID

_reb2buid - The visitor's RB2B user ID

IDE, test_cookie, 1P_JAR, NID, DV, NID
IDE, test_cookie
1P_JAR, NID, DV
NID
hblid
_reb2bgeo, _reb2bloaded, _reb2bref, _reb2bsessionID, _reb2buid

Security

These are essential site cookies, used by the google reCAPTCHA. These cookies use an unique identifier to verify if a visitor is human or a bot.

SID, APISID, HSID, NID, PREF
SID, APISID, HSID, NID, PREF