       email_id: "tem_CCcHKr95Nvu5bT7c7iHCtm"
       recipient:
         address: employer.email
-        name: employer.name
       email_data:
         new_candidates: numberOfCandidatesSinceLogin
         employer_company_name: employer.employerAt
         company_name: "CodeCombat"
-    
+    if employer.name
+      context.recipient.name = employer.name
     log.info "Sending available candidates update reminder to #{context.recipient.name}(#{context.recipient.address})"
     newSentMail =
       mailTask: @mailTaskName

    return false
  return true

createMailTask = (req, res) ->
  #unless req.user?.isAdmin() then return errors.forbidden(res)
  unless req.body.url and req.body.frequency then return errors.badInput(res)
  console.log "Creating mail task with url #{req.body.url} and frequency #{req.body.frequency}"
  newMailTask = new MailTask {}
  newMailTask.set("url",req.body.url)
  newMailTask.set("frequency",req.body.frequency)
  newMailTask.save (err) ->
    if err? then return errors.serverError(res, err)
    res.send("Created mail task!")
    res.end()
  
handleLadderUpdate = (req, res) ->
  log.info('Going to see about sending ladder update emails.')

Level = require '../levels/Level'
log = require 'winston'
sendwithus = require '../sendwithus'
if config.isProduction or config.redis.host isnt "localhost" #TODO: Ask Nick and Scott to change their environment variables and change the deploy ones
  lockManager = require '../commons/LockManager'
#TODO: Ask Nick about email unsubscriptions
createMailTask = (req, res) -> #TODO: Ask Nick whether he thinks it is a good idea or not to hardcode the mail tasks
  unless req.user?.isAdmin() then return errors.forbidden(res)
  unless req.body.url and req.body.frequency then return errors.badInput(res)
  console.log "Creating mail task with url #{req.body.url} and frequency #{req.body.frequency}"
  newMailTask = new MailTask {}
  newMailTask.set("url",req.body.url)
  newMailTask.set("frequency",req.body.frequency)
  newMailTask.save (err) ->
    if err? then return errors.serverError(res, err)
    res.send("Created mail task!")
    res.end()

module.exports.setup = (app) ->
  app.all config.mail.mailchimpWebhook, handleMailchimpWebHook
