Page tree
Skip to end of metadata
Go to start of metadata

 

Description

This function returns an email account's username or address.

Note:

If you call this function from a Webmail session URL, the system will only access data for that email account. 

Examples 


 cPanel or Webmail Session URL
https://hostname.example.com:2083/cpsess##########/execute/Email/account_name?account=user
https://hostname.example.com:2083/cpsess##########/execute/Email/account_name?account=user%40example.com
https://hostname.example.com:2083/cpsess##########/execute/Email/account_name?account=&display=anyvalue

 

Note:

This example calls the UAPI function via a cPanel session. For more information, read our Guide to UAPI documentation. 

 LiveAPI PHP Class
$cpanel = new CPANEL(); // Connect to cPanel - only do this once.
 
// Return the user email account's email address.
$get_email_acct_info = $cpanel->uapi(
    'Email', 'account_name',
    array(
        'account'    => 'user',
        )
);
 
// Return the user@example.com email address's account username.
$get_email_acct_info = $cpanel->uapi(
    'Email', 'account_name',
    array(
        'account'    => 'user@example.com',
        )
);
 
// Return "All Mail On Your Account" if "account" is empty.
$get_email_acct_info = $cpanel->uapi(
    'Email', 'account_name',
    array(
        'account'    => '',
        'display'    => 'any_value',
        )
);

Note:

For more information, read our Guide to the LiveAPI System.

 

 LiveAPI Perl Module
my $cpliveapi = Cpanel::LiveAPI->new(); # Connect to cPanel - only do this once.
 
# Return the user email account's email address.
my $get_email_acct_info = $cpliveapi->uapi(
    'Email', 'account_name',
    {
        'account'    => 'user',
    }
);
 
# Return the user@example.com email address's account username.
my $get_email_acct_info = $cpliveapi->uapi(
    'Email', 'account_name',
    {
        'account'    => 'user@example.com',
    }
);
 
# Return "All Mail On Your Account" if "account" is empty.
my $get_email_acct_info = $cpliveapi->uapi(
    'Email', 'account_name',
    {
        'account'    => '',
        'display'    => 'any_value',
    }
);

Note:

For more information, read our Guide to the LiveAPI System.

 

 cPanel Template Toolkit
<!-- Return the user email account's email address. -->
[% execute('Email', 'account_name', { 'account' => 'user' } ) %]
 
 
<!-- Return the user@example.com email address's account username. -->
[% execute('Email', 'account_name', { 'account' => 'user@example.com' } ) %]


<!-- Return "All Mail On Your Account" if "account" is empty. -->
[% execute('Email', 'account_name', { 'account' => '', 'display' => 'any_value' } ) %]

Note:

For more information, read our Guide to Template Toolkit documentation. 

 

 Command Line
uapi --user=username Email account_name account=user
uapi --user=username Email account_name account=user%40example.com
uapi --user=username Email account_name account="" display=any_value

Notes:

  • You must URI-encode values.
  • username represents your account-level username.
  • For more information and additional output options, read our Guide to UAPI documentation or run the uapi --help command. 
  • We introduced this functionality in cPanel & WHM version 56.

 Output (JSON)
{  
   "messages":null,
   "errors":null,
   "status":1,
   "metadata":{  

   },
   "data":"user@example.com"
}

Note:

Use cPanel's API Shell interface (cPanel >> Home >> Advanced >> API Shell) to directly test cPanel API calls.

   

Parameters

ParameterTypeDescriptionPossible valuesExample
accountstring

The email address to return the mail account's username. Alternately, the mail account username to return the email address.

If you do not include this parameter, the function returns All Mail On The Account, or a blank value.

  • A valid email address on the cPanel account.
  • A valid email account username.
user
displaystring

Include this parameter to cause the function to return All Mail On The Account if the account parameter is blank or does not exist.

If you do not include this parameter and the account value is blank or does not exist, the function returns a blank data value.

Any non-blank value.

any_value

Returns

ReturnTypeDescriptionPossible valuesExample
datastringThe email account information, a predetermined string, or a blank value.
  • A mail account username.
  • An email address.
  • All Mail On The Account
  • A blank value.

user@example.com