CPanel : Add email forwarder using PHP

This PHP script will add email forwarder to cPanel account by using it’s API. It’s pretty simple to call the API using PHP. For this example I’m not gonna use their SDK as it’s only one call, unless you want to call multiple API’s then their SDK is more practical.

You can download the entire script:

[box type=”download”] 


Before run this script make sure to change some settings.

*Setting part
*Change according to your cPanel settings

$fwd_to_email = "[email protected]"; //your free email eg: gmail and so on.
$fwd_from_email = "[email protected]";  //your forwarder email
$port = 2082 ;  //2082 for unsecured, 2083 for secured but your hosting must support SSL (put https in cpanellogindomain)
$cpanelpassword = "yourpass#"; //your cPanel login password
$cpanelusername = "xxxx"; //your cPanel username
$cpanellogindomain = ""; //your domain when login to cPanel without port or /cpanel .