Configuring docker mail server to relay inbound and outbound mails #3965
-
Hi, In my current setup I rented a VPS from a cloud provider of my choice. I setup DMS and it worked like a charm, I can now receive mails. 🥳 Now I wanna add on to this. Instead of having my mail lying around on a system that I don't own I'd rather have DMS act as a "proxy" for me. The VPS host has a static IP with DKIM, DMARC, SPF and the whole shebang, so it's a valid target to receive email. Instead of saving these, I'd want to have it relay the mail towards my homeserver that is also running DMS, but only has access to dyndns. I assume my VPS DMS instance doesn't care about that though and would be able to deliver the email "home"(?) So... how can I configure DMS to relay inbound mail? Should I even use DMS in that case or is it overkill? I'd be glad for any input or ideas! :3 |
Beta Was this translation helpful? Give feedback.
Replies: 5 comments 5 replies
-
Please note that this response was created using generative AI, leveraging previously available information from the repository. This information may be helpful. However, it is our strong recommendation that you carefully consider the information before blindly applying it. To configure your Docker Mail Server (DMS) instance on your VPS to relay inbound mail to another DMS instance running on your home server, you can indeed use DMS for this purpose. DMS supports relaying emails, which fits your requirement of acting as a "proxy" to relay emails to your home server. Given that your VPS has a static IP and is already configured with DKIM, DMARC, SPF, and other necessary email authentication mechanisms, it's well-prepared to act as a reliable relay. Here are the general steps you would need to follow:
Given the complexity of email systems and the potential for misconfiguration, it's essential to refer to the DMS documentation and specific configuration guides. Unfortunately, the provided context does not include direct instructions for setting up DMS as a relay in this manner, but the general approach outlined above follows standard practices for configuring mail servers for relaying. For detailed configuration options and commands, you would typically refer to the DMS documentation, Postfix documentation (since DMS uses Postfix for mail handling), and possibly your DDNS service documentation for ensuring your home server is reachable. If you're not comfortable with manual configuration or if this setup becomes too complex, you might consider simpler alternatives or using a dedicated relay service. However, given your setup and requirements, using DMS as a relay is feasible and allows you to leverage your existing infrastructure. This comment was generated by Glime. |
Beta Was this translation helpful? Give feedback.
-
Can you confirm if this is what you're wanting?
I think you should be ok with a virtual alias You then want to setup the private instance with the Relay Host support (you'll probably want to wait on the v14 release however which carries some fixes for this feature) if you won't connect directly to the public instance from your mail client, and that'd route the mail there for being sent outbound. I've seen this type of setup requested a few times. You could possibly implement it a bit differently. If you're main concern is with the storage on public VPS, I have been meaning to get the on-disk encryption feature sorted out for v15 release of DMS, which with one of the settings no one can read your mail from access to the disk storage as it'd require your credentials to decrypt. You kind of want a TCP proxy for the inbound mail (Traefik could do this), which could skip the public DMS instance on the VPS, you'd just route the traffic from the public IP / VPS to your internal DMS on another machine. Kind of need similar for routing the traffic to send back out from the public IP though unless you configure a Relay Host instead such as SendGrid or Gmail (this should be simpler, and for low traffic is free).
You might be able to leverage something like tailscale, which is similar to a VPN setup. That way your personal system and the VPS can be in a private network, but if dyndns works for you that should be fine too 👍 I'd also consider the feature I mentioned earlier for storage, I'm just not sure how that looks config wise for you. That would be handled via this ENV We have a very basic test case for this kind of setup, it uses our |
Beta Was this translation helpful? Give feedback.
-
Thank you for the detailed answer, I appreciate you took the time!
That is correct yes! I think I got a bit hung-up on the relaying part. You are likely correct that a catch-all alias would do exactly what I need. Would my mail be saved on the public instance in that case? I probably need to run my public instance with
Good idea, I can just setup wireguard to have everything in my local network and don't have to punch more holes in my firewall.
That is indeed my main concern. The current at-rest encryption implementation kinda does nothing if someone has access to the disk, since they could just read out the private key that is stored on the same system. Defeats the purpose somewhat imo |
Beta Was this translation helpful? Give feedback.
-
Alright, I've built the inbound relay with a public Postfix instance. I installed it directly instead of using DMS since the public instance should be kept very simple. I am connecting both instances via wireguard. My main.cf is
the only files I created were |
Beta Was this translation helpful? Give feedback.
-
Funnily enough when I inspect that cert I can see that my server is offering a certificate that is valid until 2034 and was issued 2 days ago. I don't think I've knowingly setup these snakeoil certs, though I might be wrong lol I was using DMS on my public instance, but I assume it's not from it since I didn't see a bindmount to the ssl folder. I guess I could setup traefik to generate a "better" certificate, similar to how I did it with DMS before on the public instance...
If this issue is something that is coming up regularly, maybe I could PR that functionality.
Would support inbound and outbound relay as before, like that.
I actually have catch-all that drops mail for users that aren't some that I explicitly defined. So that should be less of a concern for me. EDIT:
so probably it would have to be its own function |
Beta Was this translation helpful? Give feedback.
Sounds good so far! Here's some feedback if it helps :)
This should probably be configured for your actual TLS certs otherwise they're probably not going to be trusted by anyone that cares when connecting with STARTTLS on port 25 to deliver you mail on the public Postfix instance.
There was a recent issue that might have some CLI commands you can try to inspect the certs:
Should be possible to just spin up a alpine container and install the
step
package like I show at the start of that 2nd link, then use theverify
subcom…