Child pages
  • UAPI Functions - Email::list_mail_domains
Skip to end of metadata
Go to start of metadata

Description

This function lists the account's mail domains.

Important:

In cPanel & WHM version 76 and later, when you disable the MailReceive role, the system disables this function. For more information, read our How to Use Server Profiles documentation.

Examples


 cPanel or Webmail Session URL
https://hostname.example.com:2083/cpsess##########/execute/Email/list_mail_domains?select=example.com


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.
 
// List the account's mail domains.
$get_mail_domains = $cpanel->uapi(
    'Email', 'list_mail_domains',
    array(
        'select'        => 'example.com',
         )
);


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.
 
# List the account's mail domains.
my $get_mail_domains = $cpliveapi->uapi(
    'Email', 'list_mail_domains',
    {
        'select'        => 'example.com',
    }
);


Note:

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

 

 cPanel Template Toolkit
<!-- List the account's mail domains. -->
[% execute('Email', 'list_mail_domains', { 'select' => 'example.com' } ) %]


Note:

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

 

 Command Line
uapi --user=username Email list_mail_domains select=example.com


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. 
  • If you run CloudLinux™, you must use the full path of the uapi command:

    /usr/local/cpanel/bin/uapi


 Output (JSON)
{  
   "messages":null,
   "errors":null,
   "status":1,
   "metadata":{  
      "transformed":1
   },
   "data":[  
      {  
         "domain":"example.com",
         "select":1
      },
      {  
         "domain":"addondomain.com"
      },
      {  
         "domain":"subdomain.example.com"
      },
      {  
         "domain":"seconddomain.com"
      },
      {  
         "domain":"seconddomain.example.com"
      }
   ]
}


Note:

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

Parameters

ParameterTypeDescriptionPossible valuesExample
selectstring

The name of the domain that the function returns with the select output parameter.

If you do not use this parameter, the function will not return the select parameter with any domains.

A valid domain on the account.

example.com
add_wwwBoolean

Whether to list www. addresses.

This parameter defaults to 0.

  • 1 — List www. addresses.
  • 0 — Do not list www. addresses.

For example, if you specify 1, the function's output would include both   example.com   and www.example.com . If you specify 0, the output would include only example.com .

1
include_wildcardBoolean

Whether to list wildcard addresses.

This parameter defaults to 0.

  • 1 — List wildcard addresses.
  • 0 — Do not list wildcard addresses.

For example, if you specify 1, the function's output would include both   example.com   and *.example.com . If you specify 0, the output would include only example.com .

1

Returns

Note:

This function always returns the account's main domain first. 


ReturnTypeDescriptionPossible valuesExample
domainstringThe domain name.

The name of a main domain, addon domain, or subdomain on the cPanel account.

example.com

selectBoolean

A Boolean value that marks the domain that you specified in the select input parameter.

The function only returns this value if you included the select parameter when you called the function.

1 is the only possible value.

Note:

Because this value only appears if you included the select input parameter, The value always defaults to 1

1