This Node.js script uses Puppeteer to automate the process of sending activation emails for user accounts on a specific website. It reads user IDs from a file, logs into the admin portal, and sends activation emails.
- Node.js (version 14 or higher)
- An admin account for the website
puppeteer
anddotenv
Node.js packages
If you don't have Node.js installed, follow these steps:
-
Go to the Node.js official website.
-
Download and install the LTS (Long Term Support) version for your operating system.
-
Follow the installation instructions specific to your system:
- On Windows: Follow the setup wizard and complete the installation.
- On macOS: Use the
.pkg
file and follow the installation guide. - On Linux: You can use package managers like
apt
oryum
depending on your distribution.
For more detailed instructions, refer to the official Node.js installation documentation.
Once installed, confirm that Node.js is correctly installed by running the following commands in your terminal:
node -v
npm -v
These commands should print the version numbers of Node.js and npm (Node's package manager).
First, clone the repository to your local machine.
git clone https://github.com/humdek-unibe-ch/sh-send_invitation_link.git
cd sh-send_invitation_link
Install the required Node.js packages using npm
:
npm install
This will install the necessary packages like puppeteer
and dotenv
as specified in the package.json
.
Create a .env
file in the root of your project directory and add the following environment variables:
ADMIN_ACCOUNT=your_admin_username
ADMIN_PASSWORD=your_admin_password
Replace your_admin_username
and your_admin_password
with the actual admin credentials for the website.
Create a file named accounts.txt
in the root of your project directory. Each user ID should be on a new line.
Example of accounts.txt
:
33
33
33
Each user ID will be padded to 10 characters with leading zeros.
Once everything is set up, run the script using the following command:
node index.js
- The script reads user IDs from the
accounts.txt
file. - It logs into the admin website using the credentials from the
.env
file. - For each user ID, the script navigates to the user's admin page and sends an activation email.
- Make sure the website is accessible and the admin account credentials are correct.
- The script runs in non-headless mode (
headless: false
), meaning you will see the browser actions. If you want to run it in headless mode, change theheadless
option totrue
in the Puppeteer configuration.
- If the script fails to log in, verify that the credentials in the
.env
file are correct. - Ensure that the selectors used in the script match the structure of the website.
- If you encounter timeout issues, try increasing the delays between actions in the script.
Author: Nicolas Scheurer