This is part 16 of a series on sending Email

In a past post in this series, “Sending Email In C# & .NET - Part 6 - Testing SMTP Locally Using PaperCut”, we discussed how to use PaperCut as a local SMTP server to make it easier to test sending and visualizing sent email.

By this, I mean the ability for your application to send real emails, but to have something intercept them and allow you to view and inspect them, without risking the actual delivery of the email.

I have used this tool for many years, and it has proven to be very useful.

I have recently come across a tool that, I feel, is even better - Mailpit.

It works in exactly the same way, except that it uses different default ports. Which, naturally, you can change.

You can install it on your development environment (or anywhere, really), or you can use it as a Docker](https://www.docker.com/) container.

Without hesitation, I recommend the latter.

docker run -d --name mailpit -p 25:1025 -p 8080:8025 axllent/mailpit

Here, the container will use port 25 as the SMTP port and 8080 as the port for the mail client, which is what I used to use for PaperCut.

Everything should work seamlessly.

Why am I switching to this over PaperCut for testing email sending? A number of reasons.

  1. Ability to persist email (useful for multi-session development and debugging)
  2. Email is searchable
  3. The Docker image is only 39.5 MB, as opposed to PaperCut’s 269 MB (Though in the larger scheme of things, does the size really matter for a one-off download?)

Note: I am making comparisons here against the PaperCut web UI, not the desktop application.

In addition to this, there are a number of UI improvements

Message Notifications

When email is delivered, you get a notification (browser-generated)

MailpitNotification

Cleaner, Polished Interface

The interface is cleaner and a lot more polished than the web email client for PaperCut.

MailpitInbox

Search Functionality

You can search your delivered email.

MailpitSearch

Attachments Indicator

When viewing your inbox, there is an indicator for an email with attachments.

MailpitAttachment

Delete All Emails

You can delete all your email with one click.

MailpitDeleteAll

HTML Source Viewer

You can view the HTML source of the generated email

MailpitHtmlSource

HTML Check

Building on the ability to view source, Mailpit can also verify the compatibility of the HTML against modern viewers.

MailpitHtmlCheck

Headers Viewer

There is a clean viewer for all the email headers.

MailpitHeaders

Raw Message Viewer

You can also view the entirety of the email in its raw source format.

MailpitRaw

Mailpit has functionality to allow you to verify any URL links within the email.

MailpitCheckButton

Clicking the button will verify the links.

MailpitCheckResults

You can also configure Mailpit to auto-check all links on opened emails. Naturally there are some security and web traffic implications to turning this on.

MailpitAutocheck

Inline Image Counter

Mailpit has a counter that shows the number of any inline images.

MailpitInlibe

Attachments Counter

Mailpit has a counter that shows the number of any attachments.

MailpitAttachment

Device Viewer

You can also visualize how your email will appear in different devices.

Computer

MailpitDesktop

Tablet

MailpitTablet

Phone

MailpitPhone

Download Any Aspect Of The Email

You can download any aspect of the email.

MailpitDownload

Mark As Unread

You can mark email as unread.

MailpitUnread

PaperCut served me well, but time to move on to a more capable replacement.

Fare thee well, PaperCut.

Happy hacking!