简体   繁体   English

使用nodemailer发送HTML gmail后,css缺少一些规则

[英]css is missing some rules after sending a html gmail with nodemailer

I am trying to send some html that I have, as an email to my gmail account via nodemailer. 我正在尝试通过nodemailer将我拥有的一些html作为电子邮件发送到我的gmail帐户。

So at first, I sent my email like this, as plain text, to check if everything is there... 因此,起初,我以纯文本形式发送了这样的电子邮件,以检查是否所有内容都存在...

    const email =
    {
        from:    emailAddress,
        to:      sendTo,
        subject: title,
        text:    emailBody
    };

    //Send the email
    transporter.sendMail(email, function(error, info)
    {
        //If there was an error, return false as it failed to send, else true
        const emailSent = (error) ? false : true;
        return resolve(emailSent);
    });

This sends fine, all of my html is there in plain text form with all my css rules intact. 这很好,我的所有html都以纯文本格式存在,而我的所有CSS规则均完整无缺。

Then I change 然后我改变

text: emailBody

to

html: emailBody

This parses my body string to html and when I open the email, some css rules are missing. 这会将我的正文字符串解析为html,当我打开电子邮件时,缺少某些CSS规则。

For example I have an opening li tag, this is a string in my js that is part of the email body... 例如我有一个开头的li标签,这是我的js中的字符串,是电子邮件正文的一部分...

'<li style="-webkit-box-shadow: 0px 0px 3px 1px rgba(0,0,0,0.3); -moz-box-shadow: 0px 0px 3px 1px rgba(0,0,0,0.3); box-shadow: 0px 0px 3px 1px rgba(0,0,0,0.3); border-radius: 10px; padding: 20px; display: flex; justify-content: center; height: 90px; margin: 10px 0;">'

But on my email it is this... 但是在我的电子邮件中就是这样...

<li style="border-radius:10px;padding:20px;display:flex;height:90px;margin:10px 0">

So as you can see my box shadow is gone, along with my justify-content rule but the rest are intact. 因此,您可以看到我的盒子阴影消失了,我的理由-内容规则也消失了,其余的都完好无损。

Would anyone know why this is doing it? 有人知道为什么这样做吗? does gmail not like box shadows and some flex properties? gmail是否不喜欢框阴影和一些flex属性? could it be a problem with node mailer? 节点邮件程序可能有问题吗? any info is appreciated 任何信息表示赞赏

I think this is because gmail support of these properties. 我认为这是因为gmail支持这些属性。 Mail services support not many modern features that's why one still uses tables. 邮件服务不支持许多现代功能,这就是为什么仍然使用表格的原因。 You can consult what gmail supports here 您可以在这里咨询gmail支持的内容

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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