this post was submitted on 21 Jun 2023
2 points (100.0% liked)

Selfhosted

40394 readers
304 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 2 years ago
MODERATORS
 

I'm planning to migrate my email to a different provider, but they don't give much storage, so I was wondering what people would recommend for this kind of setup: basically I'd like to use the new provider as something like a relay. I'd want them to only store an email or two at a time and have some kind of self hosted solution that just grabs the emails from the provider and stores them after deleting them off the provider so it's never storing my entire email history, and also keeps my sent emails somewhere so that I have a copy of it. Ideally I'd wanna be able to set this up with a mail client like NextCloud's.

top 5 comments
sorted by: hot top controversial new old
[–] TCB13@lemmy.world 3 points 1 year ago* (last edited 1 year ago) (2 children)

The good old fetchmail is probably what you're looking for. Run your local/self-hosted email server and then use fetchmail as described here to fetch the email from the email provider and deliver into the local accounts. You also have getmail (does the same but is written in python), guide here, or go-getmail ...

Alternatively, and probably way better:

Postfix has a feature called ETRN service, documented here. It can be used to incoming emails queued deliver it to another server when a connection is available:

The SMTP ETRN command was designed for sites that have intermittent Internet connectivity. With ETRN, a site can tell the mail server of its provider to "Please deliver all my mail now". The SMTP server searches the queue for mail to the customer, and delivers that mail by connecting to the customer's SMTP server.

From what I know about it you might be able to:

  1. Configure just a SMTP/Postfix server on the cloud provider;
  2. Configure a full IMAP/SMTP server on the self-hosted / local machine;
  3. Configure the "cloud" Postfix to deliver all incoming email into your local / self-hosted Postfix using relay_domains here and here.
  4. Setup ETRN in the "cloud" provider to deal with your local server being offline / unavailable;
  5. On the local machine create a simple bash script + systemd timer / cron like this:
nc -c 'echo "ehlo selfhosted.example.org";sleep 1;echo "etrn your-domain.example.org";sleep 1;echo "quit"' remote-cloud-server.example.org 25

This command will connect to the cloud server and ask it to deliver all queued email to the self-hosted instance. This can be setup to run every x minutes, or if you want to get fancy, when the network goes up with the network-online.target target like described here. Note that the script isn't strictly necessary, is just guarantees that if the connection between servers goes down when it comes back you'll get all the queued email delivered right away.

The following links may also be of interest so your local / self-hosted email server can send email:

Now a note about NextCloud: their webmail is the worst possible solution, I wrote very detailed description of the issues here. Do yourself a favor and use Roundcube.

[–] chimay@lemmy.world 1 points 1 year ago

I use them with neomutt for years, and am happy with it.

[–] Iain@fed.rosssi.co.uk 1 points 1 year ago (1 children)

Agree about the Nextcloud client, but it's easy enough to replace it with the SnappyMail plug in which works a treat.

[–] TCB13@lemmy.world 1 points 1 year ago

Or simply run RoundCube without NC.

[–] ptz@dubvee.org 2 points 1 year ago

That sounds like POP3.

Unlike IMAP, where your inbox lives on the mail server, POP stores the messages only until you download them.

So you should be able to look for a provider that allows you to connect with POP3 and set your client up to fetch them periodically.