buy
Add Email Forwarder

Description

You can use this Add Email Forwarder API to Add Email Forwarder your Webuzo panel.

Parameters

Sample Code

You can use the following commands to create different types of forwarders:

1. Create Forwarder To Email Address:

    Specify the TO Email address and other required details.

curl --insecure -d "add=1" -d "forwarder=email" -d "domain=domain.com" -d "email=username_of_email_account " -d "femail=specify_the_TO_email_address" -u "WEBUZO_USER:USER_PASSWORD" -X POST "https://HOSTNAME_OR_SERVERiP:2003/index.php?api=json&act=email_forward"

2. Create Forwarder Fail with message:

    Set the 'fail' parameter to the fail message you want to display

curl --insecure -d "add=1" -d "forwarder=fail" -d "domain=domain.com" -d "email=username_of_email_account" -d "fail=fail message" -u "WEBUZO_USER:USER_PASSWORD" -X POST "https://HOSTNAME_OR_SERVERiP:2003/index.php?api=json&act=email_forward"

3. Create Forwarder To Your System Account:

    This type forwards emails to your system account.

curl --insecure -d "add=1" -d "forwarder=sys" -d "domain=domain.com" -d "email=username_of_email_account" -u "WEBUZO_USER:USER_PASSWORD" -X POST "https://HOSTNAME_OR_SERVERiP:2003/index.php?api=json&act=email_forward"

4. Create Forwarder Pipe to a Program:

    Specify the path of the pipe file (e.g. if pipe path is  /home/user_name/folder1/pipe_file then you need pass like this folder1/pipe_file ).

curl --insecure -d "add=1" -d "forwarder=pipe" -d "domain=domain.com" -d "email=shakir" -d "pipe_path=public_html/test_folder/test" -u "WEBUZO_USER:USER_PASSWORD" -X POST "https://HOSTNAME_OR_SERVERiP:2003/index.php?api=json&act=email_forward"

5. Create Forwarder Discard (Not Recommended):

    This type discards the forwarded emails.

curl --insecure -d "add=1" -d "forwarder=discard" -d "domain=domain.com" -d "email=shakir" -u "WEBUZO_USER:USER_PASSWORD" -X POST "https://HOSTNAME_OR_SERVERiP:2003/index.php?api=json&act=email_forward"
<?php

$user = 'Webuzo Username';
$pass = 'Password';
$host = 'ServerIP / Hostname';
 
$url = 'https://'.rawurlencode($user).':'.rawurlencode($pass).'@'.$host.':2003/index.php?api=json&act=email_forward'; 

/*
There are 5 types of forwarders you can create using the $post array you can use one at a time.
*/

// Create Forwarder  To Email Address
$post = array(
	'add' => '1',
	'forwarder' => 'email',              // Type of Forwarder  you want to set (email | pipe | sys | fail | discard)
	'domain' => 'domain.com',      		 // Valid Domain
	'email' => 'user_name',              // Specify User Name of Email account 
	'femail' => 'shakir@webuzo.com',	 // Specify the TO Email address
);

// Create Forwarder  Fail with message
$post = array(
	'add' => '1',
	'domain' => 'domain.com',      			// Valid Domain
	'email' => 'user_name',                 // Specify User Name of Email account 
	'forwarder' => 'fail',               	// Type of Forwarder  you want to set (email | pipe | sys | fail | discard)
	'fail' => 'fail message',            	// IT requreid if you set fail Forwarder  ;
);

// Create Forwarder  To Your System Account
$post = array(
	'add' => '1',
	'domain' => 'domain.com',      	// Valid Domain
	'email' => 'user_name',         // Specify User Name of Email account 
	'forwarder' => 'sys',           // Type of Forwarder  you want to set (email | pipe | sys | fail | discard)
);

// Create Forwarder  Pipe to a Program
$post = array(
	'add' => '1',
	'domain' => 'domain.com',            // Valid Domain
	'email' => 'user_name',              // Specify User Name of Email account 
	'forwarder' => 'pipe',               // Type of Forwarder  you want to set (email | pipe | sys | fail | discard)
	'pipe_path' => 'test',               // Provide the path of pipe file for example /home/user_name
);

// Create Forwarder  Discard (Not Recommended)
$post = array(
	'add' => '1',
	'domain' => 'domain.com',      // Valid Domain
	'email' => 'user_name',                 // Specify User Name of Email account 
	'forwarder' => 'discard',            // Type of Forwarder  you want to set (email | pipe | sys | fail | discard)
);

// Set the curl parameters 
$ch = curl_init(); 
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, FALSE);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 5); 
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); 

if(!empty($post)){
	curl_setopt($ch, CURLOPT_POST, 1);
	curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($post));
}

// Get response from the server. 
$resp = curl_exec($ch);
if(!empty(curl_error($ch))){
	echo curl_error($ch); die();
}

// The response will hold a string as per the API response method. 
$res = json_decode($resp, true);
// Done ?
if(!empty($res['done'])){
	echo "<pre>";
	print_r($res['done']['msg']);
	echo "</pre>";
}else{
	print_r($res['error']);
}

Output

Email forwarder successfully created.
    Was this page helpful?
    Newsletter Subscription
    Subscribing you to the mailing list