Introduction
Managing email accounts via the command line can significantly streamline server administration tasks. cPanel provides a powerful API called UAPI, which allows administrators to create email accounts without using the cPanel web interface. This method is ideal for automation, scripting, or simply performing actions more efficiently through SSH.
Prerequisites
(i) Root SSH access to the cPanel server
(ii) cPanel user already exists
(iii) Domain name already added to the cPanel account
(iv) cPanel version 11.42+ (UAPI support)
Implementation
Step 1: Log in as root or a privileged user:
$ ssh root@your-server-ip
Step 2: Identify the cPanel Username
$ grep ‘DOMAIN’ /var/cpanel/users/*
Replace Domain with the actual domain. It will show the cPanel user.
Step3: Run the UAPI Command
$ uapi –user=CPANEL_USERNAME Email add_pop \
email=’EMAIL_USERNAME’ \
domain=’DOMAIN_NAME’ \
password=’EMAIL_PASSWORD’ \
quota=QUOTA_IN_MB
Step 4: Confirm the Email Account Was Created
$ uapi –user=demoacct Email list_pops
Step 5: Test Login
Test the login via Webmail or use the credentials in an email client to verify it’s working.
Webmail URL format: https://yourdomain.com/webmail
Conclusion
Using the cPanel UAPI from the command line provides a fast, reliable way to manage email accounts without relying on the GUI. Whether you’re scripting repetitive tasks or working on a headless server, this method gives you precise control with minimal overhead