diff --git a/src/Model/User.php b/src/Model/User.php
index <HASH>..<HASH> 100644
--- a/src/Model/User.php
+++ b/src/Model/User.php
@@ -2180,7 +2180,11 @@ class User extends Base
                 $oEmail->data  = new \stdClass();
 
                 //  Add required user data to the email
-                $oEmail->data->user->username = $aUserData['username'];
+                $oEmail->data = (object) [
+                   'user' => (object) [
+                       'username' => $aUserData['username']
+                   ]
+                ];
 
                 //  If this user is created by an admin then take note of that.
                 if ($this->isAdmin() && $this->activeUser('id') != $iId) {
Improving the way the email data object is built