Email catcher for self-hosted services reddit / selfhosted ---------------------------------------------------------------------- jivanyatra · 2023-09-29 20:47 I ran across an issue when I self-hosted both psono and passbolt... I don't have an SMTP server in place, and I also didn't want to create yet another email to hook those services into. I looked around for a mail "catcher", found one, found an improvement on it, and then created a docker container for it. I figured it might be useful here to other self-hosters, since we're often privacy conscious. It's called [MailDump](https://hub.docker.com/r/jivanyatra/maildump). I'm a python dev and I was considering making one of these from scratch when I just searched to see if one already existed. I ended up finding [MailCatcher](https://github.com/sj26/mailcatcher/) which is written in PHP. Works great, dev is a stand-up guy, and there's already a docker container for it. It also has a web interface to view the emails and manage them, and it does it all in memory. I kept looking, mainly because I wanted one in python to fit into my dev workflow for other projects and I came across [ThiefMaster's MailDump](https://github.com/ThiefMaster/maildump). it has the added benefit of being able to store the emails in a sqlite database, so you don't lose them between container restarts - something that appeals to me for a project I'm working on. I sent an email but didn't get a response, and since the license allowed, I created a docker container for it (and provided all attributions). It's fairly lean (based on the alpine python container) and is for both amd64 and arm64 architectures, so raspberry pi folks can get in on it. This is great for when you need to have activation, notification, and system emails sent somewhere you can see it, but don't care to actually plug in a third party email service. It's also super helpful for testing, as you can see the test emails sent out without worrying about secrets being compromised, sending to your actual users, etc. MailTrap is a great service that exists for this purpose and also can manage sending real emails as well, in case any devs stumble on this and want something else, but for us self- hosters it's overkill and negates the point. I didn't make the software, I'm not affiliated with anything, and I get nothing from the docker container I created. I just figured someone else may also find it helpful. I think I might use MailDump to create an integration for use with a self-hosted ntfy.sh container, that way all emails can just be other notifications and it fits into a k8s cluster or docker compose stack nicely. If you're solving this issue in a different way that also avoids using a real email, I'd love to hear about it. ---------------------------------------------------------------------- thekrautboy · 2023-09-30 00:53 Or any of these: https://github.com/msztolcman/sendria https://github.com/rnwood/smtp4dev https://github.com/MattMckenzy/Mail2Gotify ---------------------------------------------------------------------- jivanyatra · 2023-09-30 02:35 Awesome, thanks for the links! I didn't end up stumbling on any of those originally. Looks like Sendria is perfect! ---------------------------------------------------------------------- maximus459 · 2023-09-30 03:01 Of all the links, only MailDump has bee updated within 8 months.. just saying ---------------------------------------------------------------------- Spaceman_Splff · 2023-09-30 12:44 That’s something I didn’t know I wanted. I wonder if I could get grafana to do the api pull on sendria. Or if it can send to syslog server. ---------------------------------------------------------------------- janjaweedIntifada · 2023-10-14 21:03 u/jivanyatra I copied your compose file. created directories e.t.c, spun up the image but cannot connect to port 8087. Connection refused, no matter what i set the port to. I can connect to 1080 within the container but cannot connect to the host port. Any ideas? Thanks for the great work ---------------------------------------------------------------------- jivanyatra · 2023-10-14 21:50 Interesting! My first thoughts are: is that port being used by another service already, or is there a firewall in place? (Docker bypasses UFW, but if you have iptables rules, those will generally still apply.) Perhaps it's an issue with the subnet that docker uses? How are you accessing it, via fqdn or IP? ---------------------------------------------------------------------- janjaweedIntifada · 2023-10-15 01:40 Both, by ip & fqdn. I am probably messing something up. I will review my stack. Thanks for getting back to me. ---------------------------------------------------------------------- jivanyatra · 2023-10-15 02:11 What OS? Ubuntu? Happy to try and help! ---------------------------------------------------------------------- janjaweedIntifada · 2023-10-15 16:21 ubuntu server 22 vm running a docker stack. This is the only container with an issue. First codeblock is container logs, second is trying to curl container IP:1080 from docker host. No firewall, nothing in the container log. tried changing host port to 9007 etc., connection is still refused. 2023-10-15T15:56:52.596751535Z -rwxr-xr-x 1 root root 402 Sep 24 23:42 start.sh 2023-10-15T15:56:53.805631007Z [2023-10-15 15:56:53] NOTICE maildump: Starting web server on http://127.0.0.1:1080 2023-10-15T15:56:53.806063430Z [2023-10-15 15:56:53] NOTICE maildump: Starting smtp server on 127.0.0.1:1025 2023-10-15T15:56:53.815446350Z [2023-10-15 15:56:53] INFO maildump.db: Using database /data/maildump.db * Trying 192.168.20.21:1080... * connect to 192.168.20.21 port 1080 failed: Connection refused * Failed to connect to 192.168.20.21 port 1080 after 0 ms: Connection refused * Closing connection 0 curl: (7) Failed to connect to 192.168.20.21 port 1080 after 0 ms: Connection refused 70b4223958f5 jivanyatra/maildump:latest Up 19 minutes maildump 0.0.0.0:1025->1025/tcp, :::1025->1025/tcp, 0.0.0.0:9007->1080/tcp, :::9007->1080/tcp ---------------------------------------------------------------------- jivanyatra · 2023-10-21 01:20 Sorry, it took me a few days to get back to you because it was a rough week. You're absolutely right! I am updating the docker image as we speak. Something about the way that flask binds on 127.0.0.1 makes it not play nice with the way docker is. I had a very customized and edited set of configs where it was working, but it's not on vanilla. I changed maildump to expect things on 0.0.0.0 (inside the container), it's working as it should. It's really important to make sure you're securing docker on a server when you run it, but it does work without issue. Mind testing it for me when you get a chance? It should be up in the next hour. ---------------------------------------------------------------------- janjaweedIntifada · 2023-10-21 15:26 It works now. thank you for creating this. Awesome job. ---------------------------------------------------------------------- jivanyatra · 2023-10-21 17:38 I'm glad! Happy to do it, and thanks for pointing out the issue! Turns out I'm having issues with the reverse proxy part of the equation now, but I'll get it sorted. It definitely works via port.