Readme: BR
A Bash script designed for system administrators to automate the creation of email accounts on cPanel/WHM servers via the command line. It utilizes the cPanel UAPI and WHMAPI1 for secure and standardized operations.
- Automated Password Generation: Uses OpenSSL to generate strong, 16-character random passwords.
- Pre-flight Checks:
- Validates email format syntax.
- Checks if the domain exists in
/etc/trueuserdomains. - Verifies if the cPanel account is currently suspended before attempting creation.
- Checks if the email address already exists to prevent overwrites.
- cPanel Native: Uses standard cPanel scripts (
/scripts/whoowns) and APIs (uapi).
- Operating System: CentOS/AlmaLinux/CloudLinux with cPanel & WHM installed.
- User: Must be executed as
root(to access WHM API and switch users for UAPI). - Dependencies:
openssl(usually pre-installed).
- Download the file to the server:
curl -O https://raw.githubusercontent.com/sr00t3d/cpanel-create-mail/refs/heads/main/cp-create-email.sh- Give execution permission:
chmod +x cp-create-email.sh- Execute the script:
./cp-create-email.sh email@domain.combash <(curl -fsSL 'https://raw.githubusercontent.com/sr00t3d/cpanel-create-mail/refs/heads/main/cp-create-email.sh') mail@dominio.com./cp-create-email.sh mail@domain.com
Success! The email account has been created.
--------------------------------------------------
Email: tmail@domain.com
Password: mEWlB7wIlQ8sacHGKg8zpg==
--------------------------------------------------- Input Validation: Ensures argument is provided and looks like an email.
- User Lookup: Identifies the cPanel owner of the domain using
/scripts/whoowns. - Safety Check: Queries
whmapi1 accountsummaryto ensure the hosting account is active (not suspended). - Creation: Executes
uapi --user=USERNAME Email add_popto create the mailbox with unlimited quota (quota=0).
- Domain not registered on server: Ensure the domain is listed in cPanel and not just a DNS pointer.
- Account is suspended: The script will block creation on suspended accounts to prevent abuse. Unsuspend the account via WHM first.
Warning
This software is provided "as is". Always ensure you have explicit permission before running. The author is not responsible for any misuse, legal consequences, or data impact caused by this tool.
For a complete, step-by-step guide, check out my full article:
👉 Fast Create cPanel Mail Account
This project is licensed under the GNU General Public License v3.0. See the LICENSE file for details.
