axllent / mailpit Goto Github PK
View Code? Open in Web Editor NEWAn email and SMTP testing tool with API for developers
Home Page: https://mailpit.axllent.org
License: MIT License
An email and SMTP testing tool with API for developers
Home Page: https://mailpit.axllent.org
License: MIT License
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.
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
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!
Hi, I got a error when send via smtp
smtp: server doesn't support AUTH
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 👍
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.
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:
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.
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!)
Is there a way to change the port numbers for SMTP and the HTTP server?
When clicking on URL in email we are getting CSP error in console (and link not opening).
Content Security Policy: Page parameters blocked resource loading http://example.com/email-verification/4a7449fbefbc5280dc50e0025c366fd8 («frame-src»).
This issue could be solved by force open all links in new tab.
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.
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.
Loading «https://mailpit.example.com/api/v1/message/89db0f92-a94b-4e43-80f1-d25866d7e1e5/raw» in frame prohibited by directive «X-Frame-Options», setted as «DENY».
DOMException: Permission denied to access property "document" on cross-origin object
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!
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")
(Stolen from mailhog/MailHog#207)
Nice to see an active similar project! Can I make a feature request?
It'd be a huge time saver to show which machine the web interface were accepted from. A filter using that would help a lot too. Thanks.
Please add a tray item in the system tray to easily start and stop the service.
Is there a way to configure an application context? I need to serve Mailpit behind a proxy at https://{hostname}/mailpit/
. However, the app artifacts (dist/app.js
, etc) do not include that context.
This behavior would be similar to MailHog's MH_UI_WEB_PATH
(docs)
It would be great if project will have OpenAPI Spec describing the backend API.
Hi @axllent thanks for releasing this.
Can I +1 for basic auth support?
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?
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!
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.
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?
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.
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"]
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
.
AuthHandler
is set.So could we
smtpd.Server.AuthMechs
to map[string]bool{"LOGIN": true, "PLAIN": true}
Or set them to true via some CLI flags.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.
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
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.
to:<term>
, from:<term>
, subject:<term>
, and also has:attachment
.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
).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
.
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.
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.
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?
Hey! Thanks for this awesome tool. I would as if you could add the "Reply-To" header to the fields displayed on top of the message?
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.
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 :)
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
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.
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
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.
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.
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)?
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.
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!
Safari handles the CSP differently and refuses to run Scripts / connect to the WebSocket. Chrome
It throws the following errors for me:
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
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.