If you want to create and give an email to someone register via your website. This tutorial may help you.
First you’re going to need to download the PHP XML API Class: https://github.com/CpanelInc/xmlapi-php
Upload it to your server and include it in the script you’re building to create email accounts.
include_once __DIR__.'/library/xmlapi/xmlapi.php'; // Need to Change the URL $ip = '123.123.123.123'; // Need to Change. $account = "cpanel_userid"; // Need to Change. $domain = "example.com.au"; // Need to Change. $account_pass = "password"; // Need to Change. $xmlapi = new xmlapi($ip); $xmlapi->password_auth($account, $account_pass); $xmlapi->set_output('json'); $xmlapi->set_port('2082'); // Need to Change. $xmlapi->set_debug(1); $results = json_decode($xmlapi->api2_query("serverusername", "Email", "addpop", array('domain' => $domain, 'email' => $new_email, 'password' => 'pw_whatyouwant', 'quota' => '200')), true); if($results['cpanelresult']['data'][0]['result']){ echo "success"; } else { echo "Error creating email account:\n".$addEmail['cpanelresult']['data'][0]['reason']; }
Note:
- Make sure you have the Services_JSON extension installed. You can do this in WHM under Module Installers>PHP Extensions and search for JSON
Views (1837)
The following two tabs change content below.

Chris Mok
Senior Developer at GNA eMarketing
Core Contributor on the WordPress.org

Latest posts by Chris Mok (see all)
- WHM – Change account setup date manually - August 25, 2016
- Manually generate the notifications to who over disk quota - August 23, 2016
- Help Desk Management: What is Level 1, Level 2, and Level 3 Help Desk support? - July 27, 2016
- Find and delete files greater than a given size from the Linux command line - April 18, 2016
- How to change WordPress default email’s From name and address - April 15, 2016