Шаблон электронной почты не отображается должным образом в Gmail и Outlook - PullRequest
2 голосов
/ 24 апреля 2019

Я отправляю письмо используя 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 ]

1 голос
/ 24 апреля 2019

Я считаю, что лучший способ сделать шаблоны одинаковыми для всех почтовых клиентов - это использовать таблицы и встроенный CSS.Однако не все свойства CSS поддерживаются во всех почтовых клиентах, поэтому вы можете проверить, какие из них имеют нормальную поддержку, а какие нет.

Вот список всех свойств и их поддержка: https://www.campaignmonitor.com/css/

1 голос
/ 24 апреля 2019

Display: grid и Display: 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>
Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...