html - gmail 和 outlook 无法正确呈现电子邮件模板

标签 html css email templates html-email

我正在使用 django 发送电子邮件, 我有这个 Django 模板:

<!DOCTYPE html>
<html lang="en" style="font-family: 'Gill Sans', 'Gill Sans MT', Calibri, 'Trebuchet MS', sans-serif;width: 100%;height: 100%;margin: 0;">
<head>
    <meta charset="UTF-8" style="box-sizing: border-box;">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <meta http-equiv="Content-Type" content="text/html charset=UTF-8">
</head>
<body style="box-sizing: border-box;width: 100%;height: 100%;margin: 0;">
    <div class="main_container" style="box-sizing: border-box;background-color: #f9f9f9;padding: 0 15px;width: 100%;height: 100%;margin: 0;">
        <div class="container" style="box-sizing: border-box;display: grid;grid-template-rows: 100px minmax(100px, auto) 100px;align-content: center;max-width: 700px;margin: 0 auto;">
            <div class="header" style="box-sizing: border-box;">
                <img src="cid:mindr_icon" style="box-sizing: border-box;width: 90px;margin: 0 auto;display: block;">
            </div>
            <div class="content" style="box-sizing: border-box;background: #fff;border-radius: 15px;box-shadow: 0 0 10px #f3f3f3;color: #454c54;padding: 10px;">
                Test Email !
            </div>
            <div class="footer" style="box-sizing: border-box;font-size: 20px;text-align: center;">
                <div class="links_footer" style="box-sizing: border-box;display: grid;grid-template-columns: 1fr 1fr 1fr;grid-template-rows: 1fr;padding: 30px 20px 10px 20px;border-bottom: 1px solid rgba(0, 0, 0, .1);width: 80%;margin: 0 auto;">
                    <a href="#" style="box-sizing: border-box;text-decoration: none;color: #454c54;font-weight: 800;text-align: left;">PRICING</a>
                    <a href="#" style="box-sizing: border-box;text-decoration: none;color: #454c54;font-weight: 800;">HELP</a>
                    <a href="#" style="box-sizing: border-box;text-decoration: none;color: #454c54;font-weight: 800;text-align: right;">CONTACT</a>
                </div>
                <div class="social_footer" style="box-sizing: border-box;padding-top: 10px;display: grid;grid-template-columns: 18px 18px 18px;grid-auto-rows: 18px;grid-gap: 18px;width: 90px;justify-content:center;margin: 0 auto;">
                    <a href="#" class="social" style="box-sizing: border-box;text-decoration: none;color: #454c54;font-weight: 800;">
                        <img src="cid:fb_ico" style="box-sizing: border-box;width: 18px;">
                    </a>
                    <a href="#" class="social" style="box-sizing: border-box;text-decoration: none;color: #454c54;font-weight: 800;">
                        <img src="cid:tw_ico" style="box-sizing: border-box;width: 18px;">
                    </a>
                    <a href="#" class="social" style="box-sizing: border-box;text-decoration: none;color: #454c54;font-weight: 800;">
                        <img src="cid:in_ico" style="box-sizing: border-box;width: 18px;">
                    </a>
                </div>
                <div class="made_with_love" style="box-sizing: border-box;padding-top: 10px;font-size: 13px;font-weight: 800;color: #575858;word-spacing: 2px;width: 80%;margin: 0 auto;">Made with <span style="color: #e25555;box-sizing: border-box;">&#9829;</span> By ____ Team</div>
            </div>
        </div>
    </div>
</body>
</html>

我的问题是大多数电子邮件客户端无法正确呈现 HTML,所以我想知道我可以更改哪些内容来解决此问题。

到目前为止,我已经测试了 Gmail、Outlook 和 MailSpring,唯一正确显示电子邮件的电子邮件客户端是 MailSpring

谢谢!

邮件 Spring : enter image description here

Gmail: enter image description here

展望: enter image description here

最佳答案

我认为使模板在所有电子邮件客户端上显示相似的最佳方法是使用表格和内联 CSS。但是,并非所有电子邮件客户端都支持所有 CSS 属性,因此您可能需要检查哪些支持良好,哪些不支持。

这是所有属性及其支持的列表:https://www.campaignmonitor.com/css/

关于html - gmail 和 outlook 无法正确呈现电子邮件模板,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55832155/

相关文章:

javascript - 如何使用 JQuery 创建动态 slider ?

email - 如何在电子邮件地址旁边制作图标

email - 即使域已通过 Mailchimp 进行身份验证并且具有有效的 SPF 和 DKIM 记录,Gmail 也会显示 "via"

html - 如何确保网站适合所有屏幕分辨率?

html - 电子邮件正文中的超链接在浏览器中有效,但在 Gmail 移动应用程序中无效

html - 更改链接样式内容后的布局问题。为什么?

javascript - 通过 firebug 控制台加载 css 样式表

python - 如何在 GAE 上使用 webapp 服务静态网页

html - 偏移表格单元格

php - 连接失败。错误 #2 : stream_socket_enable_crypto(): Peer certificate with PHPMailer