How to include doctype declaration in email template using Meteor's core email package?

Greeting Meteorites!

According to most the best way to create an html template is with an xhtml transitional doctype. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional //EN" "">
(campaignmonitor for example uses that notation for all it’s email templates) For example here’s an article

Only problem is: when using Meteor’s core email package it doesn’t allow me to send an email with a doctype declaration. To be clear - it does work without the doctype declaration - I tried it!

Here is my setup:

  1. I am storing all my email templates in a top-level private directory.
  2. I am calling the email.send method server side using the ssr:meteorhacks package to render templates with passed data.
    Here is my server side code if you are interested:

SSR.compileTemplate('htmlEmail' , Assets.getText('email/trial_ending.html'));
var emailData = {
title: "Trial Ending Soon.",
addCardUrl : "CARDURL",
year : moment().year()

to: "",
from: "Us<>",
subject: "Trial is ending.",
text: "The contents of our email in plain text.",
html: SSR.render('htmlEmail', emailData)

The error I receive is Error: Unexpected Doctype For whatever reason the email package doesn’t seem to recognize any doctype declaration! Anyone know what’s going on here?

Thank you and look forward to a response.

I fixed this with this additional method for SSR:

SSR.renderEmail = function (...args) {
	const html = SSR.render(...args);
	return `<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "">
<html xmlns="">

And removing of the same strings from template .html files.
Imo Blaze caused the problem, because it forbid to use doctype block. Only and allowed.
PS: Also you can cache compiled template outside of the method itself to compile email once. And then only fill it with data.