SmarterMail REST Wrapper

I recently switched to a web hosting provider after running my own servers for over 10 years. It's been an amazing burden off of my shoulders and has allowed me to focus on what's actually on my sites vs. what is running them.

One of the biggest challenges I faced over the years has been managing an email system that grew to close to 100,000 accounts. With the level of SPAM out there, it has been a real challenge. Now that we moved to a new provider, we no longer have the fine-grained control that we once did, but with the advent of web services it makes much of that irrelevant.

I created this CFC for managing email aliases and users on HostMySite.com's email servers, but this should work at any provider where SmarterMail's web services are made available. It has been tested with version 3 Enterprise but will probably work with others too.

The CFC has the following methods:

  • init(ServiceURL, AuthUserName, AuthPassword, DomainName) - initialize CFC (all parameters required). ServiceURL is URL of the REST Web Service (without the '/Services/...')
  • getAliases() - list all aliases.
  • getAlias(AliasName) - get forwarding addresses for a specific alias.
  • addAlias(AliasName, Addresses) - add a new alias with one or more forwarding addresses.
  • updateAlias(AliasName, Addresses) - updates alias with new forwarding addresses.
  • deleteAlias(AliasName) - removes an alias.
  • getUsers() - list all user accounts.
  • addUser(NewUsername, NewPassword, FirstName, LastName, maxMailboxSize, IsDomainAdmin) - add a new user account. maxMailboxSize is optional and defaults to 25 megabytes. IsDomainAdmin is also optional and defaults to false.
  • deleteUser(Username) - deletes a user account.
  • getDomainAliases() - list all domain aliases.
  • addDomainAlias(NewDomain) - adds a domain alias.
  • deleteDomainAlias(Domain) - deletes a domain alias.

Two test scripts are included - one which handles aliases and another user accounts. You must modify the first 3 lines of each with your account information, then just pull them up in a browser.

This is an initial release. There is nothing else planned at this time, so let me know if you need something. This should run fine on ColdFusion 6, 7, or 8, and probably earlier version too as long as you can parse an XML document.

This is released as open-source. The current version is 1.1 and you can visit the project page and download here.

Amazon S3 REST Wrapper

As my first foray into open-source code, I'm releasing a wrapper for interacting with Amazon's Simple Storage Service (S3) via REST. The wrapper is packaged as a CFC and has the following methods:

  • init(accessKeyID, secretAccessKey) - initialize CFC (both parameters required).
  • getBuckets() - List all buckets.
  • putBucket(bucketName) - create a new bucket.
  • getBucket(bucketName, prefix, marker, maxKeys) - get contents of a bucket (prefix is optional and matches on the beginning of a key, marker is optional and results start from there, maxKeys is optional and restricts the number of objects returned).
  • deleteBucket(bucketName) - delete a bucket (bucket must be empty).
  • putObject(bucketName, fileKey, contentType, HTTPtimeout) - puts an object into a bucket (HTTPtimeout is in seconds).
  • getObject(bucketName, fileKey, minutesValid) - get link to an object (minutesValid is optional and defaults to 60).
  • deleteObject(bucketName, fileKey) - delete an object from a bucket.

A simple test script is included which demonstrates the use of the CFC. You must insert your Amazon S3 access keys in the first 2 lines in s3test.cfm, then just pull it up in a browser.

This is an initial release. Future plans include support for Access Control Lists. If you need something else added, let me know.

This script should run on both ColdFusion MX 6 and 7, let me know if you run into any problems.

The current version is 1.1 and you can visit the project page and download here.