# Using Ghost with Mailhog for local newsletter testing

**URL:** <https://forum.ghost.org/t/using-ghost-with-mailhog-for-local-newsletter-testing/11558>\
**Category:** Ideas\
**Created:** [January 23, 2020, 10:18am UTC](https://forum.ghost.org/t/using-ghost-with-mailhog-for-local-newsletter-testing/11558 "2020-01-23T10:18:13Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![mrchrisadams](https://sea1.discourse-cdn.com/flex015/user_avatar/forum.ghost.org/mrchrisadams/32/5981_2.png) [@mrchrisadams](https://forum.ghost.org/u/mrchrisadams)\
**Post date:** [January 23, 2020, 10:18am UTC](https://forum.ghost.org/t/using-ghost-with-mailhog-for-local-newsletter-testing/11558/1 "2020-01-23T10:18:13Z")

</div>

Hi folks,

I often use Mailhog for testing of emails without needing to send actual email through a service like mailgun, and it seemed worth sharing here.

## What’s Mailhog?

Mailhog is an easy to install tool, that acts like an email server, letting you send email to a ‘fake’ inbox, so you can get an idea of what emails look like without needing to send them through the internet.

It’s based on the earlier Mailcatcher, which is where I pilfered this screenshot to give an idea of what these kinds of tools do:

 ![Mailcatcher screenshot](https://us1.discourse-cdn.com/flex015/uploads/ghost2/original/2X/0/0540c615db50befbb021faa9136516bb7a7f75ce.png)

However, being a single go binary, it’s easier to install and use, and you don’t need to know much about python to use it:

> **[GitHub - mailhog/MailHog: Web and API based SMTP testing](https://github.com/mailhog/MailHog)**
>
> Web and API based SMTP testing

### Using Mailhog and Ghost for testing emails.

You can use Mailhog to test sending emails, without needing to connect to the internet, if you’re on a train for example, or you’re working on templates, and need to send a few emails as a sanity check, and don’t want to cruft up your inbox:

First install Mailhog. On OS X, it’s `brew install mailhog`.

Then update `config.development.json`, to replace this:

```json
"mail": {
    "transport": "Direct"
  }

```

With this:

```json
"mail": {
    "transport": "SMTP",
    "options": {
      "host": "0.0.0.0",
      "port": 1025
    }
  },

```

And you should have easy local email testing!

This is also useful if you locked yourself out of your development environment like I just did, and forgot the password you used to get in…

Hope this helps some other soul, or even future me, when I forget and search in six months 🙂

---

<div class="post-metadata">

**Author:** ![csgeek](https://avatars.discourse-cdn.com/v4/letter/c/9de053/32.png) [@csgeek](https://forum.ghost.org/u/csgeek)\
**Post date:** [January 17, 2021, 10:14pm UTC](https://forum.ghost.org/t/using-ghost-with-mailhog-for-local-newsletter-testing/11558/2 "2021-01-17T22:14:13Z")

</div>

This is really really useful. Thank you for this little snippet. I’ve incorporated this into my docker stack for my ghost website. Not sure if anyone else will find this useful but here it is if anyone finds value in it:

```yaml
version: "3.7"

services:
  ghost:
    networks:
      - shared_backend
    image: ghost:3.38.3
    ports:
      - "8888:2368"
    restart: always
    env_file: .env
    volumes:
      - ./content:/var/lib/ghost/content/
  mysql:
    container_name: shared_mysql
    image: mysql:5.7.29
    restart: always
    env_file: .env
    networks:
      - shared_backend
    ports:
      - 3306:3306
  mail:
    image: mailhog/mailhog:v1.0.1
    container_name: mail
    ports:
      - 8025:8025
    networks:
      - shared_backend
      

networks:
    shared_backend:
        name: shared_backend
        # use a custom driver, with no options
        driver: bridge

```

env file:

```plaintext
## Database Ghost config
database__client=mysql
database __connection__ host=shared_mysql
database __connection__ user=root
database __connection__ password=testing
database __connection__ database=ghost

## Domain config
url=http://0.0.0.0

##MySQL config 
MYSQL_ROOT_PASSWORD=testing 
MYSQL_DATABASE=ghost

## MailHog Settings TESTING ONLY
mail__transport=SMTP
mail __options__ port=1025
mail __options__ host=mail

```

You’ll be able to load the browser with: [http://localhost:8025](http://localhost:8025) to see your mailhog emails and [http://localhost:8888](http://localhost:8888) for the ghost site.

---

<div class="post-metadata">

**Author:** ![alexnguyen](https://sea1.discourse-cdn.com/flex015/user_avatar/forum.ghost.org/alexnguyen/32/20114_2.png) [@alexnguyen](https://forum.ghost.org/u/alexnguyen)\
**Post date:** [September 1, 2023, 2:53am UTC](https://forum.ghost.org/t/using-ghost-with-mailhog-for-local-newsletter-testing/11558/3 "2023-09-01T02:53:35Z")

</div>

> [@mrchrisadams](#):
>
> And you should have easy local email testing!

Wow, I use MAMP Pro to run MailHog server, replace Amazon SES with your exact configuration, and it works great. No need to check REAL email.

Thank you.
