Today's Deep-Dive: Mailpit
Ep. 224

Today's Deep-Dive: Mailpit

Episode description

Malpit is a powerful, user-friendly email testing tool designed for developers, offering a safe sandbox environment to intercept, inspect, and test emails without sending them to real recipients. It acts as a local SMTP server, capturing emails sent during development and displaying them in a web interface with various viewing options, including HTML, plain text, and raw source. Malpit’s features include real-time updates via WebSockets, HTML and spam checks, link validation, message tagging, and support for MIME attachments with image thumbnails. It also offers advanced capabilities like chaos testing for simulating network failures, a REST API for automated testing, and SMTP relaying for forwarding inspected emails to real recipients. Malpit is easy to install and use, with support for multiple platforms, including Docker, and integrates seamlessly with applications by redirecting emails to its SMTP port.

Gain digital sovereignty now and save costs

Let’s have a look at your digital challenges together. What tools are you currently using? Are your processes optimal? How is the state of backups and security updates?

Digital Souvereignty is easily achived with Open Source software (which usually cost way less, too). Our division Safeserver offers hosting, operation and maintenance for countless Free and Open Source tools.

Try it now for 1 Euro - 30 days free!

Download transcript (.srt)
0:00

Welcome to the deep dive where we take your sources, articles, research, and our

0:03

own notes

0:05

and really try to pull out the most important nuggets of knowledge or insight.

0:08

Have you ever been deep in development testing an email feature maybe and then

0:13

accidentally

0:13

spammed your whole team with test subject messages? Oh yeah, been there. Or maybe

0:18

spent hours trying

0:19

to figure out why an email looked just perfect on your machine but then completely

0:22

broken,

0:23

you know, a user's actual inbox. Today we're diving into a tool that promises to

0:27

cut through

0:27

exactly that kind of complexity. But before we dive right in, just a quick word

0:31

from our supporter.

0:33

This deep dive is brought to you by Safe Server. Safe Server takes care of hosting

0:37

software like

0:37

Mailpit, the tool we're discussing today, and they actively support you in your

0:41

digital

0:42

transformation journey. You can find more information over at www.safeserver.de.

0:48

They really do help make these deep dives possible. Okay, so our mission today is

0:53

to

0:53

make understanding email and SMTP testing really easy, especially if you're just

0:58

beginning

0:58

your journey in software development. We're looking at a pretty powerful tool

1:02

called Mailpit,

1:02

and we're drawing all our insights from its GitHub repository and its official

1:05

website.

1:06

That's precisely the plan. Yeah, the sources really highlight Mailpit as, well,

1:11

small, fast,

1:11

low memory. Importantly, zero dependency and multi-platform. It's an email testing

1:16

tool,

1:17

but it also has a robust API designed specifically for developers. Think of it not

1:21

just as like

1:22

another tool, but as your crucial safe sandbox for emails. It lets you perfect your

1:27

communication

1:28

without any of those real-world mishaps we were just talking about. Okay, so let's

1:31

unpack that

1:32

a bit, especially for a beginner. What exactly is Mailpit at its core, and why is a

1:37

tool like this

1:38

so, well, necessary in the sometimes tricky world of software development? What's

1:42

really fascinating

1:42

here is its core function. It acts as a local SMTP server. Now, for anyone new to

1:47

this, an SMTP

1:48

server is basically like a digital post office for sending emails. But Mailpit's

1:53

clever twist is that

1:54

it's a fake post office, just for your development environment. It intercepts, it

1:58

scoops up every

1:59

single email sent by your application during development, holds onto them, and then

2:03

serves

2:03

them up in this really slick intuitive web interface where you can dissect and test

2:08

every

2:08

single one. Crucially, this stops any of your test emails from ever leaving your

2:12

machine and

2:12

hitting real recipients. Wow, okay. That capability sounds like it instantly gets

2:17

rid of one of the

2:17

biggest headaches for, well, pretty much any developer, right? I mean, I've

2:21

definitely sent

2:21

my share of unintentional testing 123 emails over the years. To colleagues or just

2:28

my own inbox

2:29

cluttering things up, can you tell us a bit more about the real world consequences

2:33

of not having a

2:34

tool like this beyond just, you know, a messy inbox? It really is all about

2:38

creating that safe,

2:39

controlled environment. Without something like Mailpit, you're constantly sort of

2:43

walking this

2:43

tightrope. You're either using real email services and risking accidental spam or

2:49

maybe worse. Right.

2:51

Or you're manually checking log files, maybe, and just hoping your email structure

2:54

is correct,

2:55

which is really inefficient. And our sources also mentioned that Mailpit was

2:59

inspired by an older

3:00

tool, MailHog, which isn't actively maintained anymore. Ah. So that tells us there

3:06

was a real

3:06

ongoing need in the dev community for something modern, something actively

3:10

developed in this space.

3:11

Mailpit really steps in to provide this comprehensive suite of tools for robust

3:17

email quality assurance,

3:19

making sure that when your application finally sends a real email, it's not just

3:22

delivered,

3:23

but it actually looks good and works perfectly. Okay. So we've got Mailpit's core

3:27

purpose down,

3:27

why it's such a vital sandbox, but it feels like it offers quite a bit more than

3:32

just,

3:33

you know, catching emails. When we look at the features listed in the sources,

3:38

what are the real power tools in Mailpit's toolkit? The things that truly make a

3:42

difference for

3:43

someone learning the ropes. Yeah, definitely. If we connect this to the bigger

3:47

picture,

3:48

Mailpit is really built from the ground up for simplicity and efficiency.

3:51

That's a huge benefit for anyone starting out. First off, it runs entirely from a

3:56

single static

3:57

binary or via Docker containers. Now, what that means in plain language is it's

4:02

incredibly easy

4:03

to get up and running. No complex dependencies that often trip up new developers.

4:08

You download

4:08

one file, basically, or run one simple Docker command, and you're pretty much set.

4:13

That's

4:13

fantastic. Fewer headaches with setup means more time actually developing. And the

4:17

web interface

4:18

you mentioned, that sounds like where the real interaction happens. That modern web

4:21

UI is

4:22

definitely where you interact with it, yeah. And it's designed to be very user-friendly.

4:26

You can

4:26

view your captured emails in all sorts of formats. There's a nicely formatted HTML

4:30

view, obviously.

4:32

But you can also dive into the highlighted HTML source, or just plain text, examine

4:37

all the

4:37

headers, which can be important for debugging, and even see the raw source if you

4:41

need to get

4:42

really deep into how it's constructed. It handles MIME attachments perfectly. Those

4:47

are basically

4:48

how files like images or PDFs get included in emails. And it even displays image

4:53

thumbnails

4:53

right there in the interface, so you can quickly confirm your logos or attached

4:57

images are showing

4:58

up correctly. Plus, for more advanced setups, it does have optional HTTPS and

5:03

authentication for

5:04

security. And what about the real-time updates? That sounds super helpful for live

5:08

testing. Oh,

5:08

yeah. It uses WebSockets for real-time updates. So as soon as a new email hits MailPit,

5:13

boom,

5:13

it instantly appears in your browser interface. No need to keep hitting refresh.

5:17

And it can even

5:18

give you optional browser notifications, so you know immediately when a new email

5:23

has been

5:23

intercepted. I mean, think about it, right? In the past, debugging emails often

5:27

meant send, check

5:29

logs, maybe refresh an inbox, rinse and repeat. Yeah, tedious. This instant

5:34

feedback isn't just

5:35

convenient. It fundamentally speeds up your iteration cycle. You can tweak your

5:39

email designs

5:40

or logic and see the result almost immediately. It shifts debugging from being a

5:46

chore to this

5:46

dynamic, fast feedback loop. That's a really great point. It makes the whole

5:50

development process

5:51

feel much more fluid, doesn't it? Okay, so beyond just viewing emails, you

5:55

mentioned things like an

5:55

HTML check and a spam check. For someone just starting out, why are these

5:59

particular checks so

6:01

critical before an email even leaves the development environment? These are

6:04

absolutely vital. Yeah.

6:05

MailPick goes beyond just capturing emails. It actively helps you ensure your

6:09

emails actually

6:10

look good everywhere and importantly, don't get flagged as spam. It has an HTML

6:15

check built in

6:16

that can test and score mail client compatibility. This is crucial because, as you

6:20

know, an email can

6:22

look completely different in Gmail versus Outlook versus Apple Mail. Oh, definitely.

6:26

The bane of

6:27

email developers. Exactly. So this helps catch those inconsistencies early. There's

6:32

also an

6:32

integrated link checker for all the links and images in your message, making sure

6:36

every clickable

6:37

part actually works and goes somewhere. That's handy. Broken links look unprofessional.

6:41

Right.

6:41

And for the critical spam factor, it has a spam check feature that uses a running

6:45

spam assassin

6:46

server. This helps you identify if your email content or headers might trigger spam

6:51

filters

6:51

before you ever send it to a real user. You can even generate screenshots of the

6:55

HTML messages

6:56

directly from the web UI and toggle between desktop, mobile, and tablet previews to

7:01

ensure

7:01

your emails are truly responsive. Wow. So no more sending test emails to five

7:06

different devices just

7:06

to check the layout. Okay. You're saying it's incredibly comprehensive for making

7:11

sure emails

7:11

are pretty much perfect before they go out to a customer. That alone sounds like it

7:15

saves hours

7:16

of tedious work. And for those aiming for more advanced testing, maybe integrating

7:20

this into

7:21

automated workflows, what about that chaos feature or the API? Right, the chaos

7:26

feature.

7:26

It isn't just about breaking things randomly. It's about building resilience into

7:29

your application.

7:30

The key insight here, especially for beginners, is that real world applications

7:36

will encounter

7:37

unexpected errors. Networks drop, servers glitch, things go wrong. True. Mail Pit

7:42

lets you safely

7:43

simulate these failures by enabling configurable SMTP errors. So you can proactively

7:48

design your

7:49

application to handle them gracefully, rather than just crashing unexpectedly when

7:53

something

7:53

goes wrong in production. It's about building more robust software from day one.

7:57

Kind of like

7:58

practicing for problems. Exactly. And for automated integration testing, which is a

8:03

huge part of

8:04

modern development, there's a robust REST API. This means you can programmatically

8:09

send emails

8:09

to Mail Pit, retrieve them, inspect their content, check headers. All as part of

8:14

your automated test

8:15

suite. There's also an optional webhook for receive messages. This can trigger

8:20

external processes,

8:21

maybe notify another system, seamlessly integrating email testing directly into

8:26

your continuous

8:26

integration or CI workflows. So it's definitely not just a viewer. It's a full-fledged

8:32

testing

8:32

suite that can even be automated. Got it. Any other standout features that make it

8:36

a developer's best

8:38

friend? Absolutely. For message management, it actually includes a POP3 server. POP3?

8:43

Why would

8:43

a beginner care about that? Well, it means you can actually download captured

8:46

messages directly into

8:47

your regular email client, like Outlook or Apple Mail or Thunderbird, just as if

8:52

they came from a

8:53

real server. Oh, interesting. Yeah, this is incredibly useful. If you want to test

8:57

how your emails truly

8:58

render and behave within the specific email client your users might be using, it

9:04

offers an even more

9:04

realistic testing environment beyond just the web UI. It also supports message tagging.

9:09

You can tag

9:10

emails manually in the UI or automatically using filtering rules or plus addressing.

9:15

Plus addressing,

9:16

like mymail plus tag at example.com. Exactly like that. It's fantastic for

9:21

organizing and finding

9:22

specific test emails later, especially if your app sends different types of emails.

9:27

And crucially,

9:27

it's incredibly fast at storing and processing messages. The sources say it can

9:32

handle 100 to

9:32

200 emails per second easily. Wow. And it automatically prunes old messages by

9:37

default.

9:37

It keeps the most recent 500, which ensures performance stays really snappy, even

9:42

if your

9:42

application sends a ton of emails during testing. Okay. Performance is key. But

9:46

what if you do want

9:47

to send some of those captured emails on, maybe to a real person for a final review

9:51

or something?

9:51

Good question. Mailpit offers SMTP relaying. This lets you take a captured message

9:57

when you've

9:57

inspected and then resend it via a different external SMTP server, like your actual

10:02

company

10:02

server or Gmail. You can even set up an optional allow list for recipients so you

10:07

only relay emails

10:08

to specific approved addresses, like only to the QA team's inbox, for example. Ah,

10:13

so controlled

10:14

forwarding. Right. And beyond that, it also supports just general SMTP forwarding,

10:19

which

10:19

can automatically send all captured messages to predefined external email addresses

10:24

via an external

10:25

server. So you could have your test emails not just captured, but also

10:29

automatically forwarded

10:31

to, say, a specific testing inbox for review by others. This sounds like a truly

10:35

indispensable

10:36

tool for anyone involved in software development, from total novices to seasoned

10:39

pros, it seems.

10:40

So for our listener who might be just getting started and thinking, okay, I want to

10:43

try this,

10:44

what's the absolute easiest way to install MailPit and start using it? MailPit is

10:48

designed for

10:49

incredibly easy installation across multiple platforms. Again, perfect for

10:54

beginners. If you're

10:55

on a Mac, you probably have Homebrew. It's super simple. Just type brew install

11:00

MailPit in your

11:00

terminal. That's it. Nice. And to have it run automatically in the background when

11:05

you start

11:05

your Mac, you then just type brew services start MailPit. For Linux and Mac users,

11:11

there's also a

11:12

simple installation script. You can just run from the command line. The

11:14

instructions are right there

11:15

on the website. And for Windows, Linux, and Mac users who maybe prefer not to use

11:19

package managers,

11:20

there are static binaries available. You just download the right file for your

11:24

system,

11:25

put it somewhere, and run it directly. Okay. And of course, as we mentioned, there

11:29

are widely used

11:30

multi-architecture Docker images available. If you're comfortable with Docker, that's

11:34

a very

11:34

popular and straightforward way to deploy tools like this in a contained

11:38

environment.

11:39

So lots of options depending on your comfort level and operating system. Seems like

11:43

they've

11:43

made it really accessible. Once it's installed and running, how do you actually

11:47

tell your

11:47

application to send emails to MailPit instead of, say, out to Gmail or your

11:52

corporate email server?

11:53

Right. This is the key connection. MailPit's web UI, where you view the emails,

11:58

listens by default

11:59

on HTTP.0.0.0.8025. So you can usually access that interface just by opening

12:06

HTTP.localhost.8025 in your web browser. Okay. And the SMTP port, which is where

12:11

your application

12:12

needs to send the emails, is listening on port 1025, specifically 0.0.0.1025. So

12:19

the crucial

12:19

step is configuring your sending application, whether it's PHP, Python, Node.js,

12:23

Java, whatever

12:24

you're building, to deliver its mail through MailPit's SMTP port. So change the

12:28

settings in

12:28

my app's code or config file. Exactly. It usually means changing just one or two

12:32

settings in your

12:33

application's email configuration. Where you'd normally put the address of your

12:37

real SMTP server,

12:38

like smtp.gmail.com or whatever, you'd simply put localhost as the host. And where

12:42

you'd put

12:43

the port number, like 587 or 465 for real servers, you'd put 1025. Got it. Host,

12:48

localhost, port,

12:50

2025. That's usually it. It's a quick switch that immediately redirects all your

12:55

application's test

12:56

emails directly into MailPit for inspection, instead of letting them escape out

13:00

onto the real

13:00

internet. That's a really powerful capability for configuring your application. Now,

13:05

I noticed the

13:06

sources also mentioned it can act as a substitute for send mail. Send mail is kind

13:10

of a cornerstone

13:11

for many system-generated emails, especially on Linux systems. How does MailPit

13:16

manage to integrate

13:17

with something like that, which is often quite deeply embedded in an application's

13:21

infrastructure?

13:22

Yeah, this is where it gets really convenient for certain types of applications,

13:25

especially those

13:26

running on Linux or similar systems. MailPit can act as a direct stand-in for the

13:30

send mail command.

13:31

For those unfamiliar, send mail is often the default mailman program, the mail

13:35

transfer agent,

13:36

or MTA, on many Unix-like systems. It's the behind-the-scenes program that lots of

13:41

applications

13:42

and system services use to send automated messages like error reports or

13:46

notifications.

13:46

Right, like system alerts.

13:48

Exactly. By configuring MailPit to act like send mail, you can simply tell your

13:52

entire system,

13:53

or specific applications that rely on the send mail command, to send all their

13:57

emails to MailPit

13:59

instead of trying to send them out to the real world via the actual send mail

14:02

program.

14:02

This can simplify setup immensely for complex applications,

14:07

or for just capturing all emails generated by a server during development or

14:10

testing,

14:11

without having to reconfigure every single application individually.

14:14

Wow. Okay. What an incredible deep dive into MailPit. It's really clear this tool

14:18

isn't just

14:19

about catching emails. It's about providing this comprehensive and, importantly,

14:24

incredibly

14:24

beginner-friendly environment for testing, for quality assurance, and really just

14:29

gaining

14:29

confidence in your application's email functionality, which, let's face it, can

14:34

often be a tricky part

14:34

of development. It truly simplifies what can be a complex part of the development

14:38

process,

14:39

and it empowers you, the developer, to ensure your emails are delivered correctly,

14:43

they look great,

14:43

and they behave exactly as you expect them to, all within that safe, controlled

14:47

sandbox.

14:48

It definitely removes a lot of the anxiety around email testing and debugging.

14:52

So, thinking about our listeners, what does this all mean for you? Whether you're a

14:56

seasoned

14:56

developer or maybe just writing your very first lines of code that involves sending

15:00

an email,

15:00

how does having access to a robust and accessible tool like Mailpit change your

15:05

perspective on

15:06

debugging or on refining the user experience in your applications, especially when

15:11

it comes to

15:11

critical communication like email? And maybe it makes you think, what other behind-the-scenes

15:16

tools are actually crucial for app development? Tools we might not always think

15:21

about until we

15:21

desperately need them. Something to ponder. Thank you so much for joining us on

15:26

this deep dive. We

15:27

really hope you feel much more informed now and maybe even ready to explore Mailpit

15:31

yourself.

15:31

And that safe, controlled environment we discussed is exactly what tools like Mailpit

15:36

provide,

15:36

allowing developers to focus on building great things. A big thank you once again

15:40

to our

15:40

supporter, Safe Server, for making these deep dugs possible and for helping you in

15:44

your digital

15:45

next time.

15:45

next time.