gmail和Outlook无法正确呈现电子邮件模板

时间:2019-04-24 14:11:50

标签: 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

谢谢!

Mailspring: enter image description here

Gmail: enter image description here

Outlook: enter image description here

2 个答案:

答案 0 :(得分:1)

邮件模板不支持

Display: gridDisplay: flex。试试这个:

<!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: inline-block;">
                    <a href="#" class="social" style="display: inline-block; width: 18px; margin: 0 6px; 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="display: inline-block; width: 18px; margin: 0 6px; 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="display: inline-block; width: 18px; margin: 0 6px; 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>

答案 1 :(得分:1)

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

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

相关问题