plesk-email-generator
v6.0.0
Published
Production-ready CLI tool for automated Plesk email account creation from CSV data
Maintainers
Readme
Plesk Email Account Generator
Production-ready Node.js CLI tool for automated bulk creation of student email accounts in Plesk from CSV data.
Requirements
- Node.js v14.0.0 or higher
- Linux server with Plesk installed
- CLI access via SSH
- Ability to execute plesk bin mail commands
- Domain alepuniv.edu.sy must exist in Plesk
Installation
Upload to Plesk Server
Via SCP:
scp -r plesk-email-generator [email protected]:/home/user/Via SFTP:
sftp [email protected]
put -r plesk-email-generator
exitVia Git:
ssh [email protected]
git clone https://github.com/yourusername/plesk-email-generator.git
cd plesk-email-generatorInstall Dependencies
# SSH into your Plesk server
ssh [email protected]
# Navigate to the script directory
cd plesk-email-generator
# Install dependencies
npm install
# Make script executable
chmod +x src/index.jsGlobal Installation (Optional)
You can install the package globally to run it as a command from anywhere:
# From within the directory
npm install -g .
# Now you can run:
plesk-email-genCSV Format
Your CSV file must contain the following columns:
| Column Name | Description | Example | Required | |---------------------|----------------------------------|------------------|----------| | full_name | Student's full name | John Doe | Yes | | degree | Degree code (B/M/P) | B | Yes | | graduation_year | 4-digit graduation year | 2024 | Yes | | student_card_number | Student card number (numeric, 4+ digits) | 123456789012 | Yes |
Example CSV
full_name,degree,graduation_year,student_card_number
John Doe,B,2024,123456789012
Jane Smith,M,2025,987654321098
Alice Johnson,P,2023,456789123456See examples/sample.csv for a complete example.
Usage
Run the Script
npm startOr directly with node:
node src/index.jsInteractive Prompts
The script will prompt you for:
- University Code - Used in email generation (e.g., "ALEP")
- CSV File Path - Path to your CSV file (e.g., ./data/students.csv)
Example Session
Configuration Setup
Enter university code (e.g., UNI): ALEP
Enter CSV file path: ./examples/sample.csv
Configuration Summary:
University Code: ALEP
CSV File: ./examples/sample.csv
Mode: PRODUCTION
Email accounts will be created in Plesk.Email Generation Rules
Email Address Format
{degree}{graduationYear}{universityCode}{last4CardDigits}@alepuniv.edu.syExample:
- Student: John Doe
- Degree: B (Bachelor)
- Graduation Year: 2024
- University Code: ALEP
- Card Number: 123456789012
- Generated Email: [email protected]
Degree Codes
| Code | Degree Name | |------|-------------| | B | Bachelor | | M | Master | | P | PhD |
Password Format
{fullStudentCardNumber}@ale&.comExample:
- Card Number: 123456789012
- Generated Password: 123456789012@ale&.com
Mailbox Quotas
| Degree | Quota | |--------|-------| | B | 5 MB | | M | 25 MB | | P | 5 MB |
Email Description
Student: {full_name} {graduation_year} {degree_name}Example: Student: John Doe 2024 Bachelor
Logging and Reports
Log Files
The script creates the following log files in the logs/ directory:
- success.log - Successfully created email accounts with student names
- error.log - Failed email creations with student names and reasons
Log Entry Format
[2026-01-03T21:39:41+03:00] Student: John Doe | Email: [email protected] | Status: SUCCESS
[2026-01-03T21:39:42+03:00] Student: Jane Smith | Email: [email protected] | Status: FAILED | Reason: Mailbox already existsFinal Report
A JSON report is generated at report.json:
{
"timestamp": "2026-01-03T21:39:41+03:00",
"total_processed": 5,
"successful": 4,
"failed": 1,
"failed_students": [
{
"name": "Jane Smith",
"email": "[email protected]",
"reason": "Mailbox already exists"
}
]
}Troubleshooting
Error: "Plesk CLI not available"
Cause: Script cannot access Plesk CLI commands
Solutions:
- Verify you're on a server with Plesk installed:
plesk version - Check you have permissions:
plesk bin mail --help - Try running with sudo (if appropriate):
sudo node src/index.js
Error: "CSV validation failed"
Cause: CSV file has invalid or missing data
Solutions:
- Check all required columns exist
- Verify degree codes are B, M, or P
- Ensure graduation years are 4 digits
- Confirm card numbers are numeric and 4+ digits
- Check for empty fields
Error: "Mailbox already exists"
Cause: Email address already exists in Plesk
Solutions:
- Check if student was already processed
- Verify for duplicate entries in CSV
- Manually check Plesk for existing mailbox
- Remove duplicates from CSV and re-run
Error: "Failed to create mailbox"
Cause: Plesk command execution failed
Solutions:
- Verify domain exists in Plesk
- Check disk quota on server
- Review Plesk error logs:
tail -f /var/log/plesk/panel.log
CSV Parsing Issues
Problem: Special characters in names
Solution: Ensure CSV is UTF-8 encoded:
file -i your-file.csv
# Should show: charset=utf-8License
MIT License - See LICENSE file for details
