 
   @delete: (username, callback)->
     JReferrableEmail.remove {username}, callback
+
+  invite: (callback)->
+    JMail     = require './email'
+    shareUrl  = "https://koding.com/?r=#{@username}"
+    email     = new JMail
+      from    : 'hello@koding.com'
+      email   : @email
+      replyto : 'hello@koding.com'
+      subject : "#{@username} has invited you to Koding!"
+      content : "Click here: #{shareUrl}"
+    console.log email
+    email.save (err)=>
+      return callback err  if err
+      @update $set: invited: true, callback


  @getUninvitedEmails: secure (client, callback)->
    query =
      originId : client.connection.delegate.getId()
      invited  : false
    JReferrableEmail.some query, {}, callback


        type      : Date
        get       : -> new Date
    sharedMethods :
      static      : ["getUninvitedEmails", "deleteEmailsForAccount"]
      instance    : ["invite"]

  @create: (clientId, email, callback)->
    JSession = require "./session"
