Using Smartermail Web Services and API to create domains with ColdFusion
We have moved our email services in house over to SmarterMail because of its history, power and flexibility. We used to use MailEnable, and although we like supporting Aussie companies, Smartermail is just that bit more mature.
Now to make it easy on clients and ourselves, we have minimised the amount of knowledge required to set up new domains, and by adding this code into out intranet, its now simply a case of clicking a button to have the clients domain added, and have the details available ready to hand out. Then we simply hook up the DNS and MX records and we are off!
So first its worth working out what we can actually do with the SmarterMail webservices by reading the docs.
Then take a look at the code required:
<!--- Enter the domain in here --->
<cfinvokeargument name="DomainName" value="newdomain.com">
<!--- enter the domain at the end of this line --->
<cfinvokeargument name="Path" value="D:\SmarterMail\Domains\newdomain.com">
<!--- generate a password and enter it here, save it for later so we can tell the user --->
<!--- Must comply with server regulations, currently: one numeric, one lowercase letter, and not username, min 6 chars --->
<cfinvokeargument name="PrimaryDomainAdminPassword" value="somRa2dompassword">
<!--- domain size on disk, allow 50MB per person --->
<cfinvokeargument name="MaxDomainSizeInMB" value="250">
<!--- number of mail boxes allowed on this domain--->
<cfinvokeargument name="MaxDomainUsers" value="5">
<!--- max mailbox size, perhaps calculate by the domain max disk size, divided by number of users --->
<cfinvokeargument name="MaxMailboxSizeInMB" value="50">
<cfinvokeargument name="authUserName" value="admin">
<cfinvokeargument name="authPassword" value="someR@nD0mPwd">
<!--- the username for the primary user. --->
<cfinvokeargument name="PrimaryDomainAdminUserName" value="emailroot">
<cfinvokeargument name="PrimaryDomainAdminFirstName" value="Email">
<cfinvokeargument name="PrimaryDomainAdminLastName" value="RootUser">
<cfinvokeargument name="IP" value="192.168.1.1">
<cfinvokeargument name="ImapPort" value="143">
<cfinvokeargument name="PopPort" value="110">
<cfinvokeargument name="SmtpPort" value="25">
<cfinvokeargument name="MaxAliases" value="100">
<cfinvokeargument name="MaxMessageSize" value="20000">
<cfinvokeargument name="MaxRecipients" value="200">
<cfinvokeargument name="MaxDomainAliases" value="0">
<cfinvokeargument name="MaxLists" value="0">
<cfinvokeargument name="ShowDomainAliasMenu" value="0">
<cfinvokeargument name="ShowContentFilteringMenu" value="1">
<cfinvokeargument name="ShowSpamMenu" value="1">
<cfinvokeargument name="ShowStatsMenu" value="1">
<cfinvokeargument name="RequireSmtpAuthentication" value="1">
<cfinvokeargument name="ShowListMenu" value="0">
<cfinvokeargument name="ListCommandAddress" value="list-admin">
</cfinvoke>
Now you need to put in all the arguments when consuming a webservice, if you dont want to submit a value, then have a read of Steven Erats information on How to invoke a Web Service while omitting optional service method arguments. Makes for a good read, but as an overview, you need to include one cfargument for each and every argument in the webservice. If you need to submit something as null, or no value, use
If you dont have all the arguments matched to the wsdl then you will see errors like this:
The error occurred in C:\development\localhost\httpdocs\scribble.cfm: line 40
38 : <cfinvokeargument name="RequireSmtpAuthentication" value="1">
39 : <cfinvokeargument name="ShowListMenu" value="0">
40 : <cfinvokeargument name="ListCommandAddress" value="list-admin">
41 : </cfinvoke>
42 :
Stack Trace
at cfscribble2ecfm88933367.runPage(C:\development\localhost\httpdocs\scribble.cfm:40)
coldfusion.xml.rpc.ServiceProxy$ServiceMethodNotFoundException: Web service operation AddDomain with parameters {PopPort={110},PrimaryDomainAdminLastName={Master},ShowSpamMenu={1},MaxRecipients={200},SmtpPort={25},MaxLists={0},authPassword={cosmo81Ad1m1n},MaxMailboxSizeInMB={50},ShowListMenu={0},authUserName={serv3rAdm1nU53r},ShowStatsMenu={1},IP={192.168.30.2},RequireSmtpAuthentication={1},ImapPort={143},MaxDomainSizeInMB={250},MaxDomainAliases={0},PrimaryDomainAdminUserName={emailmaster},ShowDomainAliasMenu={0},DomainName={newdomain.com.au},MaxAliases={100},ListCommandAddress={list-admin},Path={D:\SmarterMail\Domains\newdomain.com.au},ShowContentFilteringMenu={1},PrimaryDomainAdminPassword={somRa2dompassword},MaxDomainUsers={5},MaxMessageSize={20000}} cannot be found.
at coldfusion.xml.rpc.ServiceProxy.invoke(ServiceProxy.java:147)


There are no comments for this entry.
[Add Comment]