Fixed the handling of render_template when sending emails.

Way of rendering the template(html/text) is changed using the isinstance(python in-buit function).