Also tired to label your emails one by one? This Node.js project allows you to authenticate with your Gmail account and automatically label emails from specific senders. It uses the Gmail API and OAuth 2.0 for secure access.
- Authenticate with your Gmail account.
- Search for emails from specific senders.
- Automatically apply a Gmail label to matching emails.
- Stores OAuth tokens locally for reuse.
- Node.js: Ensure you have Node.js installed. You can download it here.
- Gmail API Enabled:
- Go to the Google Cloud Console.
- Create a project or use an existing one.
- Enable the Gmail API for the project.
- Create OAuth 2.0 Client Credentials and download the
credentials.json
file.
-
Clone this repository:
git clone gmail-labeling cd gmail-labeling
-
Install dependencies:
npm install
-
Add your credentials.json file:
- Place the credentials.json file (downloaded from Google Cloud Console) in the project root.
-
Run the script for the first time to generate the OAuth token:
node index.js
- Edit the list of senders and label name in the script:
Open
index.js
and modify theSENDERS
array andLABEL_NAME
variable as needed:const SENDERS = ["sender1@example.com"]; const LABEL_NAME = "Important";