snowfinch27
snowfinch27

Reputation: 149

Jade email template

I'm trying to send emails in my NodeJS app with express-mailer and I want to compose responsive emails with Jade, but I have problems with rendering this emails: styles I add to email template aren't applied to its template. For example, for the following code:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
html
    head
        meta(http-equiv = 'Content-Type', content = 'text/html; charset=UTF-8')
        style.
            body {
                background-color: #dfdfdf;
                width: 320px;
                height: 620px;
            }

            .container {
                width: 90%;
                height: 90%;
                margin: auto;
                display: flex;
                flex-deirection: column;
                background-color: white;
                border-radius: 4px;
            }
    body
        .container Hello

Rendered email in gmail looks like this: enter image description here

So, what can be my mistakes when composing such an email and how should I do it in order to get something work?

Upvotes: 0

Views: 1922

Answers (1)

Dave Newton
Dave Newton

Reputation: 160191

Many email clients expect styling to be inline and strip out CSS headers:

https://github.com/RGBboy/express-mailer/issues/28

There are tools that will do the conversions from CSS files with templates to inline CSS, e.g., https://github.com/crocodilejs/node-email-templates

Upvotes: 2

Related Questions