我使用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;">♥</span> By ____ Team</div>
</div>
</div>
</div>
</body>
</html>
我的问题是HTML没有被大多数电子邮件客户端正确地呈现,所以我想知道我可以修改什么来解决这个问题。
到目前为止,我已经测试了Gmail、Outlook和MailSpring,唯一正确显示电子邮件的电子邮件客户端是MailSpring。
谢谢!
Mailspring:

Gmail:

Outlook:

发布于 2019-04-24 14:33:16
我认为使模板在所有电子邮件客户端上类似地显示的最好方法是使用表格和内联CSS。然而,并不是所有的CSS属性都支持在所有的电子邮件客户端,所以你可能想要检查谁有ok支持和不支持。
以下是所有属性及其支持的列表:https://www.campaignmonitor.com/css/
发布于 2019-04-24 14:32:21
邮件模板中不支持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;">♥</span> By ____ Team</div>
</div>
</div>
</div>
</body>
</html>
https://stackoverflow.com/questions/55832155
复制相似问题