mail synchronizers from stupid services that don't support SMTP and other protocols
Go to file
randomuser a3ae6e23e5 add readme and license 2023-10-11 23:45:22 -05:00
img add readme and license 2023-10-11 23:45:22 -05:00
.gitignore add gitignore 2023-10-10 18:37:39 -05:00
LICENSE.md add readme and license 2023-10-11 23:45:22 -05:00
README.md add readme and license 2023-10-11 23:45:22 -05:00
common.py add readme and license 2023-10-11 23:45:22 -05:00
driver.py add readme and license 2023-10-11 23:45:22 -05:00
proton.py add readme and license 2023-10-11 23:45:22 -05:00
shell.nix sync replies back to the other side of the proxy 2023-10-11 23:00:26 -05:00

README.md

mail-sync

Synchronize mail from Protonmail and Gmail without using SMTP gateways to regular email accounts.

How does this work?

Diagram showing how mail-sync interoperates with other ecosystem tools

  • mail-sync first queries the local mail directory for any new replies to email
  • mail-sync then logs into the remote email mirroring target (e.g. Protonmail or Google) and copies any new mail
    • If there's any replies to be sent, send them too
  • Send the recent emails from the remote mailbox to the local mailbox

Why?

Two things:

  • Protonmail doesn't support using SMTP/IMAP without paying for the service. I'm trying to move off Protonmail anyway, so I'm not going to pay for it. This is the next best solution.
  • Gmail, operated by Google, sometimes doesn't support SMTP via OAuth, or however they do it. This is due to Google Workspace rules that prevent users from connecting custom email clients to their accounts.

Setting up

In order to use this, you need:

  • A Protonmail/Gmail account (Gmail is not supported at the moment)
  • A IMAP/SMTP server
    • Has to be on the same domain, mail.domain.tld or domain.tld.
    • The system for specifing email domains is still finicky; will be fixed later
  • A dedicated account on said IMAP/SMTP server for mail-sync
  • A place to operate mail-sync

Once you have all these things, first, create a secrets.py file. This file contains the usernames and passwords needed for mail-sync to operate.

Note: mail-sync will have to have your actual account password. This should sound scary to you. Be sure that you trust the mail-sync executable and the environment it's operating in.

Note: this configuration method is due to change in the near future, so don't rely on this.

Place a file named secrets.py in the root of the project directory, and include the following contents within:

class proton:
    username = "cool_protonmail_email_username"
    password = "totally_cool_password"

class gmail:
    pass # isn't implimented yet, so no login details here

class mailserv:
    hostname = "hostname.tld"
    targetusername = "localuser@hostname.tld"
    managedusername = "mailsyncdaemon@hostname.tld"
    managedpassword = "really_cool_daemon_password"

Of course, modify so that the contents make sense for your situation.

Once you have your secrets.py in place, you can run driver.py:

$ nix-shell
[nix-shell:~/git/mail-sync]$ python3 driver.py

If you're not using nix, scan the shell.nix file for the correct pip packages, then install them in a venv or globally with pip.

Things to work on

  • Make the configuration interface more polished and easier
  • Decouple some things from proton.py into modules
  • Same goes for driver.py, especially the imaplib and smtplib portions
  • When the date changes for an email in Protonmail client (e.g. from '10:22' to 'Tuesday') the system recognizes it as a new email
  • For emails imported from a remote (e.g. Protonmail or Gmail) sometimes the newlines in the message are removed
  • Package this up into a python/nix package
  • Write a NixOS module for this, so can be integrated with rndusr/dot_testing

License

Copyright (c) rndusr, aka randomuser 2023. Licensed under the AGPL v3, for more information, please see LICENSE.md.