Hacker News new | ask | show | jobs
by wolfgang42 2787 days ago
If anybody wants to do this to their own GMail account without putting trust in a third party, this is pretty easy to do with the little-known Google Apps Script. You can write JavaScript that will run on Google's servers and do whatever you want to your account. (I use this to archive various automated emails if I haven't bothered to look at them, to keep them from cluttering my inbox after they're obsolete.)

Here's a script which I think should do the job, assuming you have a filter set up to move all incoming mail to a label called 'hidden_mail' (warning: untested!):

    function checkMail() {
        GmailApp.moveThreadsToInbox(GmailApp.search('label:hidden_mail'));
    }
Just create a new project on https://script.google.com/ , paste in this code, and then Edit > Current Project's Triggers and add a trigger to run checkMail() on whatever schedule you want.
4 comments

This is awesome. I've been wanting to setup this functionality for a while, but wasn't aware of Apps Script. One thing missing in the above is to remove the 'hidden' label.

  var buffer = GmailApp.getUserLabelByName('buffered');

  function release() {
    buffer.getThreads().map(unbuffer);
  }

  function unbuffer(thread) {
    thread.moveToInbox();
    thread.removeLabel(buffer);
  }
You could automatically archive the emails with that labeling feature as well, no need for the Google Scripts.
Really, how? I've never seen any options anywhere to apply labels after a certain time. Or is there a trick I missed?
What I understood is to add labels to e-mails and archive the emails that match those labels immediately. That way, you won't get any notification for those emails. Instead, you can open the emails whenever you want. Here it is: https://cl.ly/122f791d609c
Presumably you would write the code to do it...
buremba specifically said that there wasn't any need for Google Scripts.
Off topic but I wonder why people, especially usually privacy sensitive HN readers use Gmail and turn themselves into Google's better product with nothing to gain?

Running your own server or use a more privacy catered provider with Thunderbird or whatever client isn't so hard.

Nothing to gain? How about time? That's the common benefit of every *AAS product, both free and paid.

I could self host my own email server, cloud storage and backup solution, calendar software, facebook-alternative node, blog.

Or I could use gmail, GDrive, google calendar, facebook and wordpress.

Yes, I can do everything myself, but now I'm spending my time maintaining each of those different self hosted solutions.

To pile on, gmail is also well-known to have fantastic spam and phishing prevention abilities compared to most other email solutions, something you could literally never do at home yourself without some incredible software that you run yourself (and even then probably not). That's a huge value-add for a ton of users I'd imagine.

'Nothing to gain' is incredibly hyperbolic I think or this person has never read about gmail/used gmail before.

You seem to care more about the one time setup effort than continuously feeding yourself to Google.

Besides, there are providers like Proton if you can't afford to set one up.

Convenience and security are often at odds with one another. Not that Gmail search is any good but you can't search through encrypted mail, as an example.
That's an awesome solution, thanks!