 readFile = Promise.promisify fs.readFile, fs
 
 sandbox = null
+templateCache = {}
 transport = null
 
+exports.$clearCaches = ->
+	
+	templateCache = {}
+	
 exports.$httpListening = (http) ->
 	
 	settings = nconf.get 'packageSettings:nodemailer'


	).then((html) ->
		
		if html?
			
			# Prepare the HTML to be sent as email.
			html = sandbox.prepareHtmlForEmail html.toString()
		
			# Compile it with Handlebars.
			mail.tokens ?= {}
			html = handlebars.compile(html) mail.tokens
			
	).then((html) ->
		

						
						true
						
					# Rejoin the selectors.
					selector = parts.join ','
					
					# Normalize the rule(s).
					selectors[selector] ?= ''
					selectors[selector] += rule.style.cssText.split(
					
						';'
					
					).filter((rule) ->
						
						rule isnt ''
					
					).map((rule) ->
						
						rule.trim()
						
					).sort().join '; '
					selectors[selector] += ';'
				
			# Merge as many rules as we can, so we'll have less work to do for
			# each application.
			cssTextCache = {}
			for selector, cssText of selectors
				(cssTextCache[cssText] ?= []).push selector
				
			selectors = {}
			for cssText, selectors_ of cssTextCache
				selectors[selectors_.join ','] = cssText
					
			# CREDIT: http://devintorr.es/blog/2010/05/26/turn-css-rules-into-inline-style-attributes-using-jquery/
			# With some improvements, of course.
			sandbox.inlineCss = (html) ->
				
				for selector, cssText of selectors
					for element in $(selector, $(html))
						element.style.cssText += cssText
						
			# Prepare HTML for email; inject all CSS inline and insert niceties
			# like a nav on top.
			sandbox.prepareHtmlForEmail = (html) ->
