Batch your Gmail.
Newman allows you to reduce your daily distractions by delivering your emails in batches at times you specify. Just like the old days before push notifications when you had to log onto your email service to get your emails at times you controlled.
- A Google account
- An AWS account (Lambda, S3, and SSM)
- Docker
- Python 2
- Python libraries installed:
boto
andrequest_oauthlib
- Go to Google Developers Console
- Create a new project called
Newman
- Enable the Gmail API in the Newman project
- Click Credentials on the left navbar, and then select the OAuth Consent Screen tab
- Select your email, and enter
Newman
as the product name. Click Save - Click on the Create Credentials dropdown and select OAuth Client ID
- Select application type Other and name the service
Newman
- Google will display your credentials. Click OK and then download the JSON version of the credentials. This is your client secret file
Get your AWS keys (instructions here). We recommend setting up a user for Newman first.
- Create a new filter (Settings -> Filters and Blocked Addresses -> Create a new filter)
- Put
*
into the From box. You want a filter that will cause all incoming emails to skip your inbox- You can cause certain high-priority senders' emails to arrive immediately by excluding them from this filter. For example:
* -important_sender@email.com -another_important_sender@gmail.com
- You can cause certain high-priority senders' emails to arrive immediately by excluding them from this filter. For example:
- Put
label:inbox
into the Has the words box. This will make the filter only apply to incoming emails - Click Continue, confirming when prompted
- Select the following options:
- Skip the Inbox (Archive it)
- Apply the label -> New label... -> Create a new label called
Newman
All of your incoming emails will now skip the inbox and be tagged with the label. You can always see them by clicking the Newman label on the left navbar in Gmail.
- Open your terminal
- If you do not already have them installed, install both
boto
andrequest_oauthlib
Python libraries usingpip
- Clone the Newman repo:
git clone https://github.com/jefferickson/newman.git
- Run the Newman setup and deploy script from the
newman
directory:cd newman; newman/newman_setup.py
. You will have to specify the following options or accept the defaults where possible:- Client Secret File Location [Required]: This is the file you downloaded from the Google Developers Console
- Inbox Label: The label name of your Inbox in Gmail.
- Newman Label: The label name you created in the filter above.
- Cron Setting: The default is at the top of the hour. Any valid AWS cron is valid here (both
cron()
andrate()
syntax) - AWS Access Key ID [Required]: The access key ID for your AWS user
- AWS Secret Access Key [Required]: The secret access key for your AWS user
- You will then be prompted with a URL. Copy and paste it into your web browser and log into your Gmail account. Allow Newman to access your account
- You will then be redirected to a localhost URL that probably doesn't resolve. Copy and paste this URL (starts with
https://localhost
) from your browser back into the setup script at the prompt - Newman will now:
- Store your OAuth tokens into SSM
- Start a docker image to deploy the stack to your AWS account. This may take awhile the first time you run it
- If you ever want to make changes (to the cron, for example), just rerun the setup script
That's it!