b65bb2eb73f5c398b2698c2424ca73885d571421 — Steven Guikal 2 months ago 965701c
Add Scheduled Email Sending with ProtonMail
1 files changed, 28 insertions(+), 0 deletions(-)

A content/blog/scheduled-email-protonmail.md
A content/blog/scheduled-email-protonmail.md => content/blog/scheduled-email-protonmail.md +28 -0
@@ 0,0 1,28 @@
title: "Scheduled Email Sending with ProtonMail"
date: 2021-02-10
draft: false

setTimeout(function() {$("button.mobileFull:nth-child(4)").click()}, <sec>);
This will, in the `v3.16.57` version (and maybe others) of the ProtonMail web client, automatically send the email being written in the "New Message" dialog in `<sec>` seconds. Now on to...

## The Story

My own email story is quite a convoluted one, but one I think many tech, security, and privacy-oriented folks go through. I started off with one Gmail account, progressed to two, then made a [ProtonMail](https://protonmail.com/) account, and finally moved on to my own domain with [Migadu](https://www.migadu.com/) for the mail hosting.[^1] While I am in the process of deleting Google-everything, I don't have plans on doing that for ProtonMail so I continue to use it; I like their services and occasionally use [ProtonVPN](https://protonvpn.com/).

[^1]: I could do it myself, but I'm happy to pay a little bit every year to not have to deal with maintenance, etc. Also, I save by hosting other emails with the same plan.

During one late night (read: 5:00 AM), I began an email sync between an old and new provider for one of my clients. The rather large amount of emails meant that this transfer could take a while, so I wanted to schedule an email to be sent in the morning when I estimated the transfer to complete. Now here's the thing about ProtonMail:
 - It doesn't normally support direct access through IMAP/SMTP
 - The [ProtonMail Bridge](https://protonmail.com/bridge/) allows this accesss with a paid account; I have a free one
 - [Simon Ser](https://emersion.fr) made a third-party, open-source ProtonMail bridge called [Hydroxide](https://github.com/emersion/hydroxide)

Combined with my own home-server situation of switching from Debian to [Alpine](https://alpinelinux.org/about/) but not yet setting up the Hydroxide bridge, I couldn't use any of the other standard Unix tools like `sendmail` combined with `after`. So, I resorted to my little bit of Javascript knowledge combined with some grade 2 arithmetic and figured I could automate the clicking of the "Send" button on the "New Message" dialog to occur in the morning. All I used was the [`setTimeout`](https://developer.mozilla.org/en-US/docs/Web/API/WindowOrWorkerGlobalScope/setTimeout) function, alongside a bit of jQuery which was conveniently included in the web client.[^2]

[^2]: This is totally possible without jQuery, as with technically _anything_ jQuery.

So there you have it, at least until ProtonMail [adds this feature](https://protonmail.uservoice.com/forums/284483-protonmail/suggestions/7158412-schedule-emails-in-advance) natively. Hopefully this illustrates the importance of thinking outside the ~~mail~~box and shows that the simplest solutions can be quite great for non-critical work.