Jump to content

Smartermail WSDL SOAP


jalder85

Recommended Posts

Hi,

 

I have been working on a Smartermail WHMCS module to integrate domain administrator account creation. I have been using the WSDL of Smartermail Web Services to communicate between the servers.

 

The overall intention is to be able to sell "shared" Smartermail Accounts for individual clients to use.

 

All module functions are working with the exception of the password reset and reboot server. I am choosing to leave out the reboot, but if anyone can think of another function to put in its place, let me know. DNS zone auto-create is something that will need to be tackled as well.

 

I will post the complete module code here shortly once I confirm all features are working.

 

If you have any feedback or requests regarding this, please let me know.

 

Kind Regards,

Jak

Link to comment
Share on other sites

Hi,

 

This is the early stable release. More features to come. Any requests, please let me know!

 

To set it up, just create a folder called smartermail in modules/servers/ and then paste the following code in a file smartermail.php. Create a new smartermail server in WHMCS and create product for it filling out the module configuration settings.

 

 

<?php

function smartermail_ConfigOptions() {
# Should return an array of the module options for each product - maximum of 24
   $configarray = array(
        "Domain Directory" => array( "Type" => "text", "Size" => "40", "Description" => "ex:C:\\Smartermail\\" ),
        "Default IP Address" => array( "Type" => "text", "Size" => "15", ),
        "IMAP Port" => array( "Type" => "text", "Size" => "5", ),
        "POP3 Port" => array( "Type" => "text", "Size" => "5", ),
        "SMTP Port" => array( "Type" => "text", "Size" => "5", ),
        "Max Aliases" => array( "Type" => "text", "Size" => "3", ),
        "Domain Space Quota" => array( "Type" => "text", "Size" => "5", "Description" => "MB" ),
        "Max Domain Users" => array( "Type" => "text", "Size" => "3", ),
        "Max Mailbox Size" => array( "Type" => "text", "Size" => "5", "Description" => "MB" ),
        "Max Message Size" => array( "Type" => "text", "Size" => "5", "Description" => "MB" ),
        "Max Recipients" => array( "Type" => "text", "Size" => "5", ),
        "Max Domain Aliases" => array( "Type" => "text", "Size" => "3", ),
        "Max Mailing Lists" => array( "Type" => "text", "Size" => "5", ),
        "Domain Alias Menu" => array( "Type" => "yesno", "Description" => "Tick to grant access" ),
        "Content Filter Menu" => array( "Type" => "yesno", "Description" => "Tick to grant access" ),
        "Spam Menu" => array( "Type" => "yesno", "Description" => "Tick to grant access" ),
        "Require SMTP Auth" => array( "Type" => "yesno", "Description" => "Tick to Require" ),
        "Mailing List Menu" => array( "Type" => "yesno", "Description" => "Tick to grant access" ),
        "Mail List Command Address" => array( "Type" => "text", "Size" => "12", ),

);
return $configarray;
}

function smartermail_CreateAccount($params) {

   # ** The variables listed below are passed into all module functions **

   $serviceid = $params["serviceid"]; # Unique ID of the product/service in the WHMCS Database
   $pid = $params["pid"]; # Product/Service ID
   $producttype = $params["producttype"]; # Product Type: hostingaccount, reselleraccount, server or other
   $domain = $params["domain"];
$username = $params["username"];
$password = $params["password"];
   $clientsdetails = $params["clientsdetails"]; # Array of clients details - firstname, lastname, email, country, etc...
   $customfields = $params["customfields"]; # Array of custom field values for the product
   $configoptions = $params["configoptions"]; # Array of configurable option values for the product

   # Product module option settings from ConfigOptions array above
   $configoption1 = $params["configoption1"];
   $configoption2 = $params["configoption2"];
   $configoption3 = $params["configoption3"];
   $configoption4 = $params["configoption4"];
   $configoption5 = $params["configoption5"];
   $configoption6 = $params["configoption6"];
   $configoption7 = $params["configoption7"];
   $configoption8 = $params["configoption8"];
   $configoption9 = $params["configoption9"];
   $configoption10 = $params["configoption10"];
   $configoption11 = $params["configoption11"];
   $configoption12 = $params["configoption12"];
   $configoption13 = $params["configoption13"];
   $configoption14 = $params["configoption14"];
   $configoption15 = $params["configoption15"];
   $configoption16 = $params["configoption16"];
   $configoption17 = $params["configoption17"];
   $configoption18 = $params["configoption18"];
   $configoption19 = $params["configoption19"];

   # Additional variables if the product/service is linked to a server
   $server = $params["server"]; # True if linked to a server
   $serverid = $params["serverid"];
   $serverip = $params["serverip"];
   $serverusername = $params["serverusername"];
   $serverpassword = $params["serverpassword"];
   $serveraccesshash = $params["serveraccesshash"];
   $serversecure = $params["serversecure"]; # If set, SSL Mode is enabled in the server config

# Code to perform action goes here...

$wsdl = "http://".$serverip.":9998/Services/svcDomainAdmin.asmx?wsdl";
$param=array('AuthUserName'=>$serverusername, 
		'AuthPassword'=>$serverpassword,
                       'DomainName'=>$domain,
                       'Path'=>$configoption1.$domain,
                       'PrimaryDomainAdminUserName'=>$username,
                       'PrimaryDomainAdminPassword'=>$password,
                       'PrimaryDomainAdminFirstName'=>$clientsdetails['firstname'],
                       'PrimaryDomainAdminLastName'=>$clientsdetails['lastname'],
                       'IP'=>$configoption2,
                       'ImapPort'=>$configoption3,
                       'PopPort'=>$configoption4,
                       'SmtpPort'=>$configoption5,
                       'MaxAliases'=>$configoption6,
                       'MaxDomainSizeInMB'=>$configoption7,
                       'MaxDomainUsers'=>$configoption8,
                       'MaxMailboxSizeInMB'=>$configoption9,
                       'MaxMessageSize'=>$configoption10,
                       'MaxRecipients'=>$configoption11,
                       'MaxDomainAliases'=>$configoption12,
                       'MaxLists'=>$configoption13,
                       'ShowDomainAliasMenu'=>$configoption14,
                       'ShowContentFilteringMenu'=>$configoption15,
                       'ShowSpamMenu'=>$configoption16,
                       'ShowStatsMenu'=>'1',
                       'RequireSmtpAuthentication'=>$configoption17,
                       'ShowListMenu'=>$configoption18,
                       'ListCommandAddress'=>$configoption19,
		);
$smartclient = new soapclient($wsdl, $param);
$successful=$smartclient->AddDomain($param);

if ($successful) {
	$result = "Account has been created!";
} else {
	$result = "Great Failure! Please address issue...";
}
return $result;
}

function smartermail_TerminateAccount($params) {
   $domain = $params["domain"];
   $serverusername = $params["serverusername"];
   $serverpassword = $params["serverpassword"];
   $serverip = $params["serverip"];
# Code to perform action goes here...
       $wsdl = "http://".$serverip.":9998/Services/svcDomainAdmin.asmx?wsdl";
       $param=array('AuthUserName'=>$serverusername,
                       'AuthPassword'=>$serverpassword,
                       'DomainName'=>$domain,
		'DeleteFiles'=>'0'
                       );
       $smartclient = new soapclient($wsdl, $param);
       $successful=$smartclient->DeleteDomain($param);

   if ($successful) {
	$result = "Domain Deleted Successfully";
} else {
	$result = "Error";
}
return $result;
}

function smartermail_SuspendAccount($params) {
   $domain = $params["domain"];
   $serverusername = $params["serverusername"];
   $serverpassword = $params["serverpassword"];
   $serverip = $params["serverip"];
# Code to perform action goes here...
       $wsdl = "http://".$serverip.":9998/Services/svcDomainAdmin.asmx?wsdl";
       $param=array('AuthUserName'=>$serverusername,
                       'AuthPassword'=>$serverpassword,
                       'domainName'=>$domain,
                       );
       $smartclient = new SoapClient($wsdl, $param);
       $successful=$smartclient->DisableDomain($param);

   if ($successful) {
	$result = "Domain Disabled Successfully";
} else {
	$result = "Error";
}
return $result;
}

function smartermail_UnsuspendAccount($params) {
   $domain = $params["domain"];
   $serverusername = $params["serverusername"];
   $serverpassword = $params["serverpassword"];
   $serverip = $params["serverip"];
# Code to perform action goes here...
       $wsdl = "http://".$serverip.":9998/Services/svcDomainAdmin.asmx?wsdl";
       $param=array('AuthUserName'=>$serverusername,
                       'AuthPassword'=>$serverpassword,
                       'domainName'=>$domain,
                       );
       $smartclient = new soapclient($wsdl, $param);
       $successful=$smartclient->EnableDomain($param);


   if ($successful) {
	$result = "Domain Enabled Successfully";
} else {
	$result = "Error";
}
return $result;
}

function smartermail_ChangePassword($params) {
   $domain = $params["domain"];
   $serverusername = $params["serverusername"];
   $serverpassword = $params["serverpassword"];
   $serverip = $params["serverip"];
       $username = $params["username"];
       $password = $params["password"];
   $clientsdetails = $params["clientsdetails"]; # Array of clients details - firstname, lastname, email, country, etc...
# Code to perform action goes here...
       $wsdl = "http://".$serverip.":9998/Services/svcUserAdmin.asmx?wsdl";
       $param=array('AuthUserName'=>$serverusername,
                       'AuthPassword'=>$serverpassword,
                       'EmailAddress'=>$username."@".$domain,
                       'NewPassword'=>$password,
                       'NewFirstName'=>$clientsdetails['1'],
                       'NewLastName'=>$clientsdetails['lastname'],
                       'IsDomainAdmin'=>'1',
                       );
       $smartclient = new soapclient($wsdl, $param);
       $successful=$smartclient->UpdateUser($param);

   if ($successful) {
	$result = "Domain Admin Password Updated";
} else {
	$result = "Error";
}
return $result;
}

function smartermail_ChangePackage($params) {
   # ** The variables listed below are passed into all module functions **

   $serviceid = $params["serviceid"]; # Unique ID of the product/service in the WHMCS Database
   $pid = $params["pid"]; # Product/Service ID
   $producttype = $params["producttype"]; # Product Type: hostingaccount, reselleraccount, server or other
   $domain = $params["domain"];
       $username = $params["username"];
       $password = $params["password"];
   $clientsdetails = $params["clientsdetails"]; # Array of clients details - firstname, lastname, email, country, etc...
   $customfields = $params["customfields"]; # Array of custom field values for the product
   $configoptions = $params["configoptions"]; # Array of configurable option values for the product

   # Product module option settings from ConfigOptions array above
   $configoption2 = $params["configoption2"];
   $configoption3 = $params["configoption3"];
   $configoption4 = $params["configoption4"];
   $configoption5 = $params["configoption5"];
   $configoption6 = $params["configoption6"];
   $configoption7 = $params["configoption7"];
   $configoption8 = $params["configoption8"];
   $configoption9 = $params["configoption9"];
   $configoption10 = $params["configoption10"];
   $configoption11 = $params["configoption11"];
   $configoption12 = $params["configoption12"];
   $configoption13 = $params["configoption13"];
   $configoption14 = $params["configoption14"];
   $configoption15 = $params["configoption15"];
   $configoption16 = $params["configoption16"];
   $configoption17 = $params["configoption17"];
   $configoption18 = $params["configoption18"];
   $configoption19 = $params["configoption19"];

   # Additional variables if the product/service is linked to a server
   $server = $params["server"]; # True if linked to a server
   $serverid = $params["serverid"];
   $serverip = $params["serverip"];
   $serverusername = $params["serverusername"];
   $serverpassword = $params["serverpassword"];
   $serveraccesshash = $params["serveraccesshash"];
   $serversecure = $params["serversecure"]; # If set, SSL Mode is enabled in the server config

       # Code to perform action goes here...

       $wsdl = "http://".$serverip.":9998/Services/svcDomainAdmin.asmx?wsdl";
       $param=array('AuthUserName'=>$serverusername,
                       'AuthPassword'=>$serverpassword,
                       'DomainName'=>$domain,
                       'IP'=>$configoption2,
                       'ImapPort'=>$configoption3,
                       'PopPort'=>$configoption4,
                       'SmtpPort'=>$configoption5,
                       'MaxAliases'=>$configoption6,
                       'MaxDomainSizeInMB'=>$configoption7,
                       'MaxDomainUsers'=>$configoption8,
                       'MaxMailboxSizeInMB'=>$configoption9,
                       'MaxMessageSize'=>$configoption10,
                       'MaxRecipients'=>$configoption11,
                       'MaxDomainAliases'=>$configoption12,
                       'MaxLists'=>$configoption13,
                       'ShowDomainAliasMenu'=>$configoption14,
                       'ShowContentFilteringMenu'=>$configoption15,
                       'ShowSpamMenu'=>$configoption16,
                       'ShowStatsMenu'=>'1',
                       'RequireSmtpAuthentication'=>$configoption17,
                       'ShowListMenu'=>$configoption18,
                       'ListCommandAddress'=>$configoption19,
                       );
       $smartclient = new soapclient($wsdl, $param);
       $successful=$smartclient->UpdateDomain($param);


# Code to perform action goes here...

   if ($successful) {
	$result = "Domain Limits Updated";
} else {
	$result = "Error";
}
return $result;
}

function smartermail_ClientArea($params) {
$loginurl = "http://".$params["serverip"].":9998/Login.aspx";
$code = '<form action="'.$loginurl.'" method="post" target="_blank">
<input type="hidden" name="shortcutLink" value="autologin" id="shortcutLink">
<input type="hidden" name="email" id="email" value="'.$params["username"].'@'.$params["domain"].'" />
<input type="hidden" name="password" id="password" value="'.$params["password"].'" />
<input type="submit" value="Login to Admin Webmail Panel" />
</form>';
return $code;
}

function smartermail_AdminLink($params) {
$loginurl = "http://".$params["serverip"].":9998/Login.aspx";
       $code = '<form action="'.$loginurl.'" method="post" target="_blank">
<input type="hidden" name="shortcutLink" value="autologin" id="shortcutLink">
<input type="hidden" name="email" id="email" value="'.$params["serverusername"].'" />
<input type="hidden" name="password" id="password" value="'.$params["serverpassword"].'" />
<input type="submit" value="Login as Admin" />
</form>';
       return $code;
}


/**function smartermail_AdminCustomButtonArray() {
# This function can define additional functions your module supports, the example here is a reboot button and then the reboot function is defined below
   $buttonarray = array(
 "New Function" => "newfunction",
);
return $buttonarray;
}**/


?>

 

 

Regards,

jalder

Link to comment
Share on other sites

  • 1 month later...
  • 3 months later...

Hi,

 

My apologies for the ridiculous delay in response. I should probably look into setting up email notification on post replies....

 

Anyways,

Been kept busy lately so I havent had much imagination time to script up new features. If there is something in particular you are looking for, or a specific change in existing functionality then please let me know jack at jalder dot com. It is so much easier to script up specific requests than to think up features :)

 

Just taking a quick look at the script again Im thinking maybe its time for some SSL encrypted traffic between WHMCS and Smartermail (vote for it and I'll see about getting it done). Paranoia these days.... if it ain't encrypted, it ain't cool :)

 

Thanks!

 

jalder

Link to comment
Share on other sites

  • 1 year later...

You Update Server Plugins?

 

Hi,

 

My apologies for the ridiculous delay in response. I should probably look into setting up email notification on post replies....

 

Anyways,

Been kept busy lately so I havent had much imagination time to script up new features. If there is something in particular you are looking for, or a specific change in existing functionality then please let me know jack at jalder dot com. It is so much easier to script up specific requests than to think up features :)

 

Just taking a quick look at the script again Im thinking maybe its time for some SSL encrypted traffic between WHMCS and Smartermail (vote for it and I'll see about getting it done). Paranoia these days.... if it ain't encrypted, it ain't cool :)

 

Thanks!

 

jalder

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use & Guidelines and understand your posts will initially be pre-moderated