Introduction
Managing email accounts is a common task for cPanel administrators. While email accounts can be viewed through the cPanel interface, server administrators with root or SSH access can also list email accounts directly from the command line.
This can be useful when managing multiple cPanel accounts, troubleshooting mailbox-related issues, or quickly verifying which email accounts are configured under a particular cPanel account.
Prerequisites
Before proceeding, make sure you have:
- Root or SSH access to the cPanel server.
- A cPanel account username.
- Access to the cPanel server command line.
- A server running cPanel & WHM.
Implementation
List Email Accounts Using UAPI
cPanel provides the uapi command-line utility to interact with cPanel’s UAPI functions.
Use the following command:
| $ uapi –user=username Email list_pops |
Replace username with the required cPanel account username.
For example:
| $ uapi –user=webasebrandings Email list_pops |
The command will display the email accounts associated with the specified cPanel account along with available mailbox information.
Display the Output in JSON Format
You can also use JSON output when you need a structured response:
| $ uapi –user=username –output=jsonpretty Email list_pops |
This format can be useful when processing the output through scripts or other command-line tools.
List Mailboxes from the Server
cPanel stores mailboxes under the cPanel user’s home directory.
The general mailbox location is:
/home/USERNAME/mail/
This will display the domains configured for mail under the cPanel account.
To view the individual mailbox directories, use:
find /home/USERNAME/mail/ -mindepth 2 -maxdepth 2 -type d
Example output:
/home/USERNAME/mail/domain.com/info
/home/USERNAME/mail/domain.com/admin
/home/USERNAME/mail/example.com/support
Recommended Method
For cPanel administration, using UAPI is generally preferable when we need information about configured email accounts:
| $ uapi –user=username Email list_pops |
The filesystem method can be useful when troubleshooting or checking the actual mailbox directories on the server.
Conclusion
Listing email accounts through the command line can make cPanel email administration faster and easier, especially when managing multiple accounts or troubleshooting mail-related issues. The cPanel UAPI Email list_pops function provides a convenient way to retrieve mailbox information without accessing the cPanel interface.
FAQs
1. Can I list cPanel email accounts without logging into WHM?
Yes. If you have appropriate SSH access, you can use the cPanel UAPI command from the command line.
2. What command is used to list email accounts in cPanel?
Use:
uapi --user=username Email list_pops
Replace username with the cPanel account username.
3. Where are cPanel mailboxes stored?
Mailboxes are generally stored under:
/home/USERNAME/mail/
Related Articles:
How to Increase Email Account Disk Quota Using WHM API? – PheonixSolutions Knowledge-Base
Talk to our experts:
Have a technology challenge or looking for the right solution for your business? Our team can help you with cloud, DevOps, development, infrastructure, design, and more. Feel free to reach out to our experts here.