简体   繁体   中英

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: 在此处输入图片说明

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

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, eg, https://github.com/crocodilejs/node-email-templates

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM