       return done()
 
   processLicenseRequest: (teacherEmail, userID, leadID, licensesRequested, amount, done) ->
+    # log.info("DEBUG: closeIO.processLicenseRequest #{teacherEmail} #{userID} #{leadID} #{licensesRequested} #{amount}")
+
     # Update lead with licenses requested
     licensesRequested = parseInt(licensesRequested)
     putData = 'custom.licensesRequested': licensesRequested

          activities = JSON.parse(body)
          return done("Unexpected activities format: " + body) unless activities.data?
          for activity in activities.data when activity._type is 'Email'
            if /@codecombat\.(?:com)|(?:nl)/ig.test(activity.sender) and not activity.sender?.indexOf(config.mail.username) >= 0 and not activity.sender?.indexOf('brian@codecombat.com') >= 0
              return done(null, activity.sender, activity.user_id, lead.id)
          return done(null, config.mail.supportSchools, lead.id)
    catch error
      log.error("closeIO.getSalesContactEmail Error for #{email}: #{JSON.stringify(error)}")
      return done(error)

  sendMail: (fromAddress, subject, content, salesContactEmail, leadID, done) ->
    # log.info("DEBUG: closeIO.sendMail #{fromAddress} #{subject} #{content}")
    matches = salesContactEmail.match(/^[a-zA-Z_]+ <(\w+@[a-zA-Z_]+?\.[a-zA-Z]{2,3})>$|(\w+@[a-zA-Z_]+?\.[a-zA-Z]{2,3})/i)
    salesContactEmail = matches?[1] ? matches?[2] ? config.mail.supportSchools
    salesContactEmail = config.mail.supportSchools if salesContactEmail?.indexOf('brian@codecombat.com') >= 0

    postData =
      to: [salesContactEmail]
      sender: config.mail.username

request = require 'request'

apiKey = config.closeIO?.apiKey
defaultSalesContactUser = 'user_Fh0uLUkRIKMk2to61ISq8PneyQonuD2i7hes6RhZgDX'

module.exports =
  logError: (msg) ->
