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

 

Description

This function lists a domain's forwarders.

Examples 


 cPanel or Webmail Session URL
https://hostname.example.com:2083/cpsess##########/execute/Email/list_forwarders?domain=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 example.com's forwarders.
$list_forwarders = $cpanel->uapi(
    'Email', 'list_forwarders',
    array(
        'domain'     => '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 example.com's forwarders.
my $list_forwarders = $cpliveapi->uapi(
    'Email', 'list_forwarders',
    {
        'domain'     => 'example.com',
    }
);

Note:

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

 

 cPanel Template Toolkit
<!-- Get a hash of all the data, then display the forwarded email. -->
[% data = execute( 'Email', 'list_forwarders', { 'domain' => 'example.com' } ); %]
[% FOREACH q = data.forward %]
     <p>
         [% q %]
     </p>
[% END %]
 
<!-- Get only the forwarded address. -->
[% execute('Email', 'list_forwarders', { 'domain' => 'example.com' }).data.forward %]

Note:

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

 

 Command Line
uapi --user=username Email list_forwarders domain=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. 
  • We introduced this functionality in cPanel & WHM version 56.

 Output (JSON)
{
  "messages": null,
  "errors": null,
  "status": 1,
  "data": [
    {
      "html_dest": "forwarded@example.com",
      "dest": "forwarded@example.com",
      "html_forward": "user@example.com",
      "forward": "user@example.com",
      "uri_forward": "user%40example.com",
      "uri_dest": "forwarded%40example.com"
    }
  ],
  "metadata": {
    "transformed": 1
  }
}


Note:

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

Parameters

ParameterTypeDescriptionPossible valuesExample
domainstring

Required

The domain.

A valid domain on the account.

example.com
regexstring

A Perl Compatible Regular Expression (PCRE) that filters the results.

If you do not use this parameter, the function returns results for all of the account's filters.

A valid PCRE.user

Returns

ReturnTypeDescriptionPossible valuesExample

uri_dest

string

The forwarded address.

An email address on the cPanel account in a URI-encoded format.

forwarded%40example.com

forward

string

The forwarded mail's destination.

The location to which the system sends forwarded mail.user@example.com

html_dest

string

The forwarded address.

The location to which the system sends forwarded mail in an HTML-compatible format.

forwarded@example.com

uri_forward

string

The forwarded mail's destination.

An email address on the cPanel account in a URI-encoded format.

The location to which the system sends forwarded mail in a URI-encoded format.

user%40example.com

dest

string

The forwarded address.

An email address on the cPanel accountforwarded@example.com

 

html_forward

string

The forwarded mail's destination

The location to which the system sends forwarded mail in an HTML-compatible format.user@example.com