14

Hey-ho 👋

What is the best approach for selfhosting an email server with static IP or blocked port 25?

I've done it many times in many different ways, now doing it again and want to hear what is the best approach these days

My port 25 isn't even probably blocked, I just prefer to use my vps to help it with this stuff

Any suggestions?

you are viewing a single comment's thread
view the rest of the comments
[-] TCB13@lemmy.world 4 points 9 months ago* (last edited 9 months ago)

You can selfhost the email server wherever you want. But you've to use some external system to deliver the email or you'll end up in spam because your residential IP is most likely dynamic and already flagged by most email providers.

One way to do it is to get a VPS somewhere and setup Wireguard on it. Then configure your local system to bind to the Wireguard interface and IP so all email send and received using the tunnel. Dovecot doesn't care what interface it is running on, Postfix has specific options that you can change in master.cf to accommodate the fact that it will be binding to the VPN IP and the real IP is the VPS public IP.

  1. Setup a install of Dovecot / Postfix / Rspamd on your local server: https://workaround.org/ispmail-bookworm/
  2. Start by setting up a Wireguard tunnel between your local server and the VPS: https://www.digitalocean.com/community/tutorials/how-to-set-up-wireguard-on-ubuntu-20-04
  3. Create a outgoing transport for the email that uses the WG tunnel and is aware of the VPS public IP:
out-wg      unix  -       -       n       -       -       smtp
 -o proxy_interfaces=188.xxx.xxx.xxx # the real public IP of the VPS
 -o smtp_bind_address=10.0.0.2 # the IP that your local server has on the WG interface
 -o inet_interfaces=10.0.0.2 # same as above
 -o myhostname=server.example.org # should match the PTR / reverse DNS entry on the VPS IP
 -o smtp_helo_name=server.example.org # should match the PTR / reverse DNS entry on the VPS IP
 -o syslog_name=smtp-wg
  1. Set your VPS firewall to NAT/forward incoming traffic on port 25, 587, 465 and 993 to the local server (wireguard client 10.0.0.2);
  2. Change main.cf to use the transport by adding: default_transport = out-wg.

That's everything you need to get it going. Use https://www.mail-tester.com/ to debug if DKIM and everything else is properly setup at the end.

[-] stown@sedd.it 2 points 9 months ago

Very nice walkthrough. Gonna bookmark this.

this post was submitted on 29 Jan 2024
14 points (85.0% liked)

Selfhosted

40330 readers
167 users here now

A place to share alternatives to popular online services that can be self-hosted without giving up privacy or locking you into a service you don't control.

Rules:

  1. Be civil: we're here to support and learn from one another. Insults won't be tolerated. Flame wars are frowned upon.

  2. No spam posting.

  3. Posts have to be centered around self-hosting. There are other communities for discussing hardware or home computing. If it's not obvious why your post topic revolves around selfhosting, please include details to make it clear.

  4. Don't duplicate the full text of your blog or github here. Just post the link for folks to click.

  5. Submission headline should match the article title (don’t cherry-pick information from the title to fit your agenda).

  6. No trolling.

Resources:

Any issues on the community? Report it using the report flag.

Questions? DM the mods!

founded 1 year ago
MODERATORS