Code Monkey home page Code Monkey logo

mailpit's People

Contributors

adiabatic avatar apreiml avatar axllent avatar corvan avatar dependabot[bot] avatar derknerd avatar gliwka avatar henningp avatar jonaskuske avatar jouve avatar jrmessias avatar kaptinlin avatar lupinitylabs avatar macbookandrew avatar maximilian-krauss avatar mfechner avatar oforialexander avatar richieri avatar shizunge avatar thomasjepp avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

mailpit's Issues

IMAP/POP3 support?

Hi there,
I'm currently looking for an alternative for greenmail, mostly because they don't have a web interface for reading captured mails. Judging by their issue tracker there were requests and attempts to add one in the past, but without any result.
Now, mailpit has a nice web interface, but apparently doesn't offer IMAP/POP3. 😄

Rationale for why this could be useful: I have a couple of projects with fairly sophisticated end-to-end tests, all running in an encapsulated dockerized environment. Some of those tests have workflows like "Register a new user through the web ui, poll the user's inbox via IMAP until the account confirmation mail has arrived, then open the confirmation link."

Any chance you would be interested in implementing this?

Wrong html santitization for search column

Hello, it seems something is wrong with HTML sanitization when you build the search column. it looks like some tags were ignored and not unwrapped to text. As a result, when you try to find the email by word in the body, you can't get it.

To reproduce, I'll attach a zipped eml file. In this case, the text "massmailgoodhost" will be dropped, and the "search" field will not contain it.

example.com - sales [email protected] massmail testufof9hiyjgo8best regards! liam nison [email protected] https //www.example.com test. https //portal.example.com/services/my/15413 you have received this notification because you are a example.com customer.email address [email protected] is attached to account 11092.

It seems like a bug of https://github.com/k3a/html2text, but instead of it, why not use the Text field of the envelope structure, which returns the eml parser (github.com/jhillyerd/enmime)?

d80e6ca4-fb3c-4dcb-a6f8-030af2f8278f.eml.zip

Windows EXE

Please release a Windows EXE installer for Mailpit with a system tray icon. Just like Syncthingy! This way it will be easy to install on Windows and with a system tray, easy to start and stop Mailpit without using a terminal.

404 to api while using webroot

I am launching mailpit with --webroot mailpit but I get a 404 in the UI. The URL returning the 404 is:
http://somehost:8025/mailpit/api/v1/messages?limit=50

Without --webroot the URL is:
http://somehost:8025/api/v1/messages?limit=50
and this works.

Change port numbers in GUI

Please add setting to change the port numbers for SMTP and the web GUI within the web GUI. After changing the port numbers, it will require you to restart the service for the changes to take effect.

Need assistance in using mailpit in our app

Hello;
We're trying to move away from mailhog and instead use mailpit in our wamp stack but are running into an issue where the service doesn't start. I suspect it has something to do with this line https://github.com/Bearsampp/Bearsampp/blob/99c82d0152bf766427dfc223b1f33918eb8c0846/core/classes/bins/class.bin.mailpit.php#L6
we're not php pro's so this is a bit of a daunting task for us.
We're the only 100% portable WAMP stack that I'm aware of so I'd really like to support this exposure of this project by adding mailpit to our software.
Perhaps someone here could lend some guidance?
Thanks in advance
Bear

p.s. here's our config for mailpit
https://github.com/Bearsampp/module-mailpit/blob/main/bin/mailpit1.1.5/bearsampp.conf

Change ports?

Is there a way to change the port numbers for SMTP and the HTTP server?

Switch backend storage to use SQLite

CloverDB (which uses BadgerDB) works really well for Mailpit, however it does come with some massive overheads (for just a small application), and with hindsight just isn't the right choice for Mailpit.

Two reported issues currently affected by this are #8 and #9, and is likely also related to #3.

Comparing CloverDB and SQLite (native Go port) with a persistent database (written to disk) containing 100,000 emails:

BadgerDB SQLite
Insert 100 messages 500ms 1,500ms
Memory usage (persistent data) 400-2,500MB 8-20MB
Idle CPU usage 2-3% CPU 0% CPU
Messages index load 9ms 21ms
Single word search 70ms 32ms
Three word search 3,756ms 1,264ms

Note: these are approximate & average values, tested on my laptop (SSD + Intel i7-7600U CPU @ 2.80GHz), and were using actual emails varying in size (ie: not just a simple plain text text email). The values are used simply for a comparison.

Findings

  • Data storage speeds reduce quite significantly with SQLite, although I am still able to process and store approximately 75 emails per second (versus 200 per second with CloverDB). SQLite must also use a single query at a time, to very heavy use can result in delayed responses. Both implementations use zstd to compress the raw email in the database to save space.
  • The runtime memory requirements are huge by comparison, with SQLite requiring 50-125 times less RAM than CloverDB/BadgerDB at all times.
  • BadgerDB appears to use 2-3% CPU when idle (unsure why), SQLite does not suffer from this.
  • UI response time is similar for message lists and message loading.
  • Single word searches are similar in response time, however SQLite performs much better with multi-word searches.
  • The implementation of SQLite also allows Mailpit to perform more defined searching within specific fields, currently limited to:<term>, from:<term>, subject:<term>, and also has:attachment.
  • BadgerDB does reclaim some space after deleting enough messages, however it isn't clear exactly how & when this works, and apparently requires the database to be closed and re-opened, plus some additional data written to to the database to activate the pruning. SQLite can run a periodic VACUUM to reclaim space (automatically via Mailpit when needed), which reverts the entire database to less than 40KB when all messages are deleted (Delete all).

Implementation & testing

  • Mailpit currently allows either persistent storage, or in-memory storage. Whilst SQLite also has a feature to run in-memory, the chosen approach will be to store "non-persistent" data to a temporary file instead of RAM, which is then automatically deleted on exit. This will mean that memory usage is not directly linked to the number of messages.
  • Testing on Windows / Mac needs to be done prior to merging in any code.

Breaking changes

Once implemented, the switch to SQLite will mean that any existing user data is useless, and should be manually deleted to free up space. The database formats are not interchangeable, and once I implement SQLite the original data will no longer be usable. Given the major change, the next release should likely jump a major version, ie: 1.0.0.

Tray

Please add a tray item in the system tray to easily start and stop the service.

Use go.mod-compliant version tags

Mailpit currently tags releases with strings like 1.2.3. Unfortunately, go.mod requires version tags to be prefixed with a v, e.g. v1.2.3.

Could you switch to this way of version tagging? If you do, the mailpit entry in the go.mod wouldn't look like

github.com/axllent/mailpit v0.0.0-20221015230430-ea12a1ee566e

but like:

github.com/axllent/mailpit v1.2.5

which makes it much easier to see which version you're building against.

Healthcheck endpoint

Hello, awesome project! Could a healthcheck endpoint be added? Just an endpoint that can be used to check if the service is healthy. It is useful in docker-compose etc.

[Feature] Always support authentication even without STARTTLS

I am testing Vaultwarden which uses the library lettre sending emails. I set SMTP_SECURITY=off and use empty username and password for testing. (I will refer vaultwarden as client below)

Mailhog could receive the email. On the other hand, when connecting to mailpit, the client gives me No compatible authentication mechanism was found.

Digging into the code, it is due to mailpit does not send 250-AUTH in the EHLO response. We need the following condition to send 250-AUTH.

  1. tls is enabled. See here
  2. AuthHandler is set.

So could we

  1. Set smtpd.Server.AuthMechs to map[string]bool{"LOGIN": true, "PLAIN": true} Or set them to true via some CLI flags.
  2. Always set a AuthHandler even if there is no config.SMTPAuthFile provided. We can always return true in the new handler and log the username and password for debug purpose.

The above settings may not make sense in a real SMTP server. But it is nice to have these options in mailpit.

Search broken

INFO[2023/01/10 22:48:43] [smtp] starting on 0.0.0.0:1025              
INFO[2023/01/10 22:48:43] [http] starting server on http://0.0.0.0:8025/ 
ERRO[2023/01/10 22:52:10] sql: Scan error on column index 5, name "FromJSON": converting NULL to string is unsupported 

go version go1.19.4 freebsd/amd64
mailpit version: 47a556d

Any way to see info on BCC?

Really unsure if this is possible but it would be great if we can confirm who is in the BCC field. When the email is received in Mailpit, the headers (correctly) won't show this. The Mailpit API shows a field for "BCC" which always is empty when I check. I have tests (Laravel project) to confirm the presence of a BCC recipient but no way to verify again with a concrete example using Mailpit.

Thank for your work on Mailpit!

Harddrive storage size

Hi,

first of all, a big thank you for your amazing work !

It is not necessarily a big issue, but I find a bit weird that I got a 2GB+ file in the storage directory while there is only 4 emails... with small attachments.

image
image

Invalid chars in webroot too strict

I think the invalid char list for the webroot is a bit too strict. Currently only [^0-9a-zA-Z\/-] is supported but I think there should be at least _ allowed too.

For example when hooking Mailhog into an "internal path" that has special access rights, even in non-production environments. For example https://my.service/_internal/mailpit.

Would it be possible to add at least _ to the list of allowed chars? Maybe also . would make sense - think https://my.service/internal.mailpit

OpenAPI / Swagger schema

One of the reason for which I arrived to this project is because I was frustrated by the fact that after having built a client for Mailhog based on the schema file I had to discover that the provided schema was in no way matching the reality, making me just waste time.
I am not a go programmer, I mostly use Python and Django and as such I find very convenient the automated schema generation. It seems that there is something similar for Go projects that generates the schema parsing the code as explained here.
Maybe somebody can take a look. It would help a lot such schema so automatically could be generated API clients for MailPit in the most wide range of programming languages.
Here an example on how to comment the code so that the schema can be generated and kept in sync with the code.

Feature request: Messages retention

Hello, thank you for such a good tool. We use mailpit for our staging installations, but sometimes we get a lot of message from staging. This requires wiping the mailpit database to reduce the consumption of disk space.

It would be great if mailpit got feature like retention policy/retetion time, to delete old messages and prevent the mailpit database bloat.

mailpit.png 404 page not found

When an email is received whilst MailPit browser tab is open.
I get an error in network console.

mailpit.svg does exist

image

Email forwarding

I don't think this is the intention of the project, but wanted to throw an idea out there.

Amazon SES is one of the more economic production SMTP services, but it doesn't offer an interface for seeing which emails are sent to who, at what time, with what contents - that's why projects like SES Dashboard exist.

Mailpit could provide all that context for a production app, but forward along the email to SES for deliverability. Too out of scope? Thanks!

MP_TAG does not work

Tags don't work when defined with MP_TAG environment variable. Works fine with -t command.

Test:
docker run --rm -it -p 1025:1025 -p 8025:8025 -e MP_TAG="abc=\"ABC\"" axllent/mailpit:v1.3.2 -v

Looks like default value is missing:
https://github.com/axllent/mailpit/blob/master/cmd/root.go#L145:

- rootCmd.Flags().StringVarP(&config.SMTPCLITags, "tag", "t", "", "Tag new messages matching filters")
+ rootCmd.Flags().StringVarP(&config.SMTPCLITags, "tag", "t", "config.SMTPCLITags", "Tag new messages matching filters")

Easily view email headers

Is it possible to add a section to the email information that shows the headers sent with the email?

There already is an endpoint of the api that allows you to retrieve the headers (api/v1/message/<ID>/headers) but its not used in the webUI.
Being able to easily inspect the headers would be very useful as searching for them in the raw email can be difficult.

Provide structs of API v1 responses for use in client code

Moved from #15 (comment):

The structs used for the API response are currently a bit scattered over the project (like apiv1.MessagesResult and storage.Message or storage.Summary). Is there any chance you could provide these structs in a central place (perhaps apiv1 is the right package already) and allow/encourage them being imported from client projects? That would be extremely handy!

I'm not fully into the internals, but maybe you could do a simple type alias (type MessageSummary = storage.Summary) in the apiv1 package so you don't need to copy them as long as v1 is the latest API. Once you internally switch to something else you could change the type alias to become the struct that resembles whatever the APIv1 returns.

Docker image

Hi and thanks for this project 👍

If interested, I created a multiarch docker image for mailpit. I integrated it in my docker image sandboxes (I use buildah for multiarch build):

I don't know how do you want to handle the docker image, nor how do you plan to automate its deployment, would you be interested by a pull request ?

ARG CI_REGISTRY
FROM golang:1.19-alpine as builder
ARG VERSION=0.0.4
ARG GOOS
ARG GOARCH
ARG GOARM

RUN echo "Will build on GOOS/GOARCH/GOARM: ${GOOS}/${GOARCH}/${GOARM}" \
  && apk --no-cache add --virtual build-dependencies \
    git npm \
  && git clone -b ${VERSION} --depth 1 https://github.com/axllent/mailpit.git \
  && cd mailpit \
  && npm install \
  && npm run build \
  && CGO_ENABLED=0 GOOS=${GOOS} GOARCH=${GOARCH} GOARM=${GOARM} go build -ldflags "-s -w" -o /mailpit

FROM scratch

COPY --from=builder /mailpit /mailpit

ENTRYPOINT ["/mailpit"]

Logs flooded with RunValueLogGC() messages

Hello,

I'm running Mailpit in Ubuntu 20.04.4 and log get flooded every few minutes with this message:

RunValueLogGC(): Value log GC attempt didn't result in any cleanup

which I think is related to CloverDB/BadgerDB. Here's a screenshot:

Screenshot 2022-08-21 at 17 34 14

I also tried to run Mailpit with in-memory storage, but still log get flooded again with another message:

RunValueLogGC(): Cannot run value log GC when DB is opened in InMemory mode

This is my Mailpit service running:

[Unit]
Description=Mailpit
After=network.target
[Service]
User=pi
ExecStart=/home/pi/go/bin/mailpit --data /home/pi/mailbox --max 150
[Install]
WantedBy=multi-user.target

Lastly, just to note that the Mailpit process is constantly consuming 2.5~3.5% CPU, which is quite high compared to the Mailhog instance it replaced.

Screenshot 2022-08-21 at 17 37 46

mailpit 0.1.5 compiled with go1.19 on arm64.

(Nevertheless, Mailpit still brings a much better experience than Mailhog, thank you for your work!)

Automatic SSL/TLS

I saw the docs about pointing to an existing SSL/TLS certificate: https://github.com/axllent/mailpit/wiki/HTTPS

Another Go project, PocketBase, automatically issues Let's Encrypt certs if you pass the --https flag: ./pocketbase serve --http="mysite.com:80" --https="mysite.com:443"

It looks like they use https://pkg.go.dev/golang.org/x/crypto/acme/autocert

Here's how it is implemented in their server code: https://github.com/pocketbase/pocketbase/blob/master/cmd/serve.go#L61

Would something like that align with the roadmap for Mailpit? It's an awesome project by the way, thanks for all your hard work!

Can the API be considered stable?

Version 1.0.0 is out, but the API (/api/...) is not documented outside the code (yet?). So I'm unsure if it's just an internal API (for Frontend<->Backend communication) or whether it is safe (and stable) to use it externally?

My use case is I want to run integration tests and check the mails that are being sent, so I collect the messages via the MailPit websocket endpoint. It seems quite convenient to me, but if that API is subject to change, I shall better not use it.

On a side note, thanks for sharing this excellent software!

[Feature request] Download HTML file

I've found Mailhog to be invaluable and I'm very glad this project exists, thanks for your efforts :)

One task I often perform is to test an email and then provide the design with sample content for others to review. To help with this I sometimes use a screenshot or copy/paste the HTML from the relevant tab but it would be great to be able to simply download an .html file.

key/pem handling for smtp

trying here to configure smtps and STARTTLS (optional) for the docker image.
I can also rebuild the docker image [EDIT id nessesary ] and already have let'sencrypt the key & cert.

The wiki's smtp page mentions the config options --smtp-ssl-cert and --smtp-ssl-key

I can not set them, though & don't know if it is possible from env variables too (trying to avoid the execute docker config service option if possible.

Edit 2: The codebase's config.go also does not mention these options...

Thumbs up for the project 👍

Support for dynamic tags

The tagging systems is really great! But currently it's a bit static as that you have to define the tags in advance.

My use case: Have a single Docker container for Mailpit and allow other (which are unknown before starting Mailpit) Docker containers via Traefik to use this Mailpit container to capture all emails. Now I'd like to have a tag which contains the source of the mail which is usually the host of the sender address. I'm calling this dynamic tags which could be defined with a regular expression like this:

--tag '$1=/@(.*)$/'

$1 would contain the matched group.

Does this make sense? Are tags the right thing for this since it seems like they apply to the whole message and not only a specific header?

IDEA: Add selection box and sort features

Hello,

just trying to improve this already awesome job.

This could be nice to be able to select multiple mails to delete them at once.

Also, been able to sort the emails by column (sender, date, size, etc) would be great too.

Thanks,
Florent

Planning on ignoring -o flag for sendmail ?

Hello, I just discovered your project as a replacement for Mailhog and it works great ;)

I want to use Mailpit to unit test a PHP project which we handle SMTP and sendmail, and we use an external mailer framework (PHPMailer) which uses the -o flag for the sendmail command and we get an error : unknown shorthand flag: 'o' in -oi.

I know that for Mailhog, they added it a long time ago (https://github.com/mailhog/mhsendmail/blob/master/cmd/cmd.go).

Thanks in advance :)

GUI not loading all messages

When opening the webclient not all messages are displayed.
The behavior seems a very random. At each refresh different messages are shown. Only very few occasions show all messages.

First pageload;
image

Second pageload;
image

Third pageload
image

v0.0.7, using -d parameter for datastorage.

Add EXPOSE to Dockerfile

Some CI environments look for the list of ports exposed by a container as a way of doing a basic "health check" to verify that the container is running and ready to accept requests. GitLab is one such CI environment. Without an EXPOSE statement in the Dockerfile, the gitlab-runner has no way of checking if the mailpit container is ready to operate as a service or if more time is needed. An error is logged in this case, although it doesn't really affect operation (at least in my tests).

Simply adding the line EXPOSE 1025 8025 to Dockerfile resolves the issue. If a different set of ports is used (i.e. via --smtp or `--listen`` command-line options, then this would require changing the Dockerfile. But I see this as unlikely for a CI environment, as ports can be re-mapped between containers.

ERROR 0.0.0.0:1025: bind: Only one usage of each socket address (protocol/network address/port) is normally permitted.

I got this error when running mailpit command in PS (Windows).

PS C:\Users\Isaac> mailpit
INFO[2023/03/22 17:32:34] [smtp] starting on 0.0.0.0:1025
INFO[2023/03/22 17:32:34] [http] starting server on http://0.0.0.0:8025/
ERRO[2023/03/22 17:32:34] listen tcp 0.0.0.0:1025: bind: Only one usage of each socket address (protocol/network address/port) is normally permitted.

How to resolve this?

Configuring the Tool

Hello, I've installed it sucessfully and are able to view the dashboard (not tried smtp so far)
Now i would like to secure the smtp server auth auth credentials and specify an email it is going to send messages from.
For this i would need an configuration file but couldn't locate one in the directory.

CSP: Safari does not load Script / connect to WebSocket due to CSP errors

Safari handles the CSP differently and refuses to run Scripts / connect to the WebSocket. Chrome
It throws the following errors for me:
image

Setup:
I'm running Mailpit via docker (latest image) and access it via the current Safari (Version 15.6.1 (17613.3.9.1.16)) on MacOS Monterey Version 12.5.1.

As a workaround i've downgraded back to 1.1.3, so it's at least not an immediate issue for me.

Related:
It seems as if the connect-src 'self' issue is already known and has possibly been fixed in an upcoming version of safari:
w3c/webappsec-csp#7

Flatpak

Please release a Flatpak package for Mailpit with a system tray icon. Just like Syncthingy! This way it will be easy to install on all Linux distros and with a system tray, easy to start and stop Mailpit without using a terminal.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.