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

						
						true
						
					# Rejoin the selectors, and cache the associated rules.
					selector = parts.join ','
					
					selectors[selector] ?= ''
					selectors[selector] += rule.style.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
					$(selector, $(html)).each (i, elm) ->
						elm.style.cssText += cssText
			
			# Prepare HTML for email; inject all CSS inline and insert niceties
			# like a nav on top.
			sandbox.prepareHtmlForEmail = (html) ->


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