diff --git a/modules/hosting/client/hosting_client.module b/modules/hosting/client/hosting_client.module
index 6d2d5c2..0ca954f 100644
--- a/modules/hosting/client/hosting_client.module
+++ b/modules/hosting/client/hosting_client.module
@@ -275,7 +275,7 @@ function hosting_client_register_user($node) {
       $to = $node->email;
     }
 
-    $variables = array(
+    $params = array(
       '!username' => $user->name, 
       '!site' => variable_get('site_name', 'Drupal'), 
       '!password' => $pass, 
@@ -283,25 +283,28 @@ function hosting_client_register_user($node) {
       '!uri_brief' => substr($base_url, strlen('http://')), 
       '!date' => format_date(time()), 
       '!login_uri' => url('user', array('absolute' => TRUE)), 
-      '!edit_uri' => url('user/'. $account->uid .'/edit', array('absolute' => TRUE)), 
+      '!edit_uri' => url('user/'. $user->uid .'/edit', array('absolute' => TRUE)), 
       '!login_url' => user_pass_reset_url($user));
     // No e-mail verification is required, create new user account, and login user immediately.
-    $subject = _hosting_client_mail_text('welcome_subject', $variables);
-    $body = _hosting_client_mail_text('welcome_body', $variables);
-//    drupal_mail('hosting-client-register-welcome', $to, $subject, $body);
-    /* TODO Create a hook_mail($key, &$message, $params) function to generate
-    the message body when called by drupal_mail. */
-    $account = array(); // Set this as needed
-    $language = user_preferred_language($account);
-    $object = array(); // Replace this as needed
-    $context['subject'] = $subject;
-    $context['body'] = $body;
-    $params = array('account' => $account, 'object' => $object, 'context' => $context);
+    $language = user_preferred_language($user);
     drupal_mail('hosting_client', 'hosting-client-register-welcome', $to, $language, $params);
   }
 }
 
 /**
+ * Implementation of hook_mail()
+ */
+function hosting_client_mail($key, &$message, $params) {
+  switch ($key) {
+    case 'hosting-client-register-welcome':
+      $message['subject'] = _hosting_client_mail_text('welcome_subject', $params);
+      $message['body'] = _hosting_client_mail_text('welcome_body', $params);
+    break;
+  }
+}
+
+
+/**
  * Implementation of hook_update().
  *
  * As an existing node is being updated in the database, we need to do our own
