UAPI Functions - Email::account_name

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

 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',
        )
);

 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',
    }
);

 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' } ) %]

 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.

 Output (JSON)

   "messages":null,
   "errors":null,
   "status":1,
   "metadata":{ 
 
   },
   "data":"user@example.com"
}

 

Note:

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

 

Parameters

 Parameter 

Type

Description

Possible values

 Example 

account

 string 

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 

display

string

 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

 Return 

 Type

Description

Possible values

Example

data

 string 

 The 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 

 

  • 13 Users Found This Useful
Was this answer helpful?

Related Articles

The cPanel Interface

For  cPanel  &  WHM  version  58 Overview The cPanel interface is...

User Preferences

For cPanel & WHM version 58 Overview This document outlines how to access your cPanel...

Manage External Authentications

For cPanel & WHM version 58 Overview Manage credentials Additional documentation...

What is cPanelID?

In This Article:  Overview ServicesHow to get a cPanelID cPanelID External...

Guide to cPanel Interface Customization - cPanel Style Development

Introduction You can develop custom styles that modify the appearance of the cPanel interface....