[英]How can I preserve HTML/CSS formatting between email client and HTML web page?
I have a client that uses Google Mail's IMAP library to read HTML email from a Gmail inbox, then uploads said email to a database for retrieval and display on a web page. 我有一个客户端,该客户端使用Google Mail的IMAP库从Gmail收件箱中读取HTML电子邮件,然后将所述电子邮件上载到数据库以进行检索并显示在网页上。 The idea is to have all company-wide emails available in a centralized location for reference by employees.
想法是在集中位置提供所有公司范围内的电子邮件,以供员工参考。
I have all the code working to grab the emails from Gmail, insert into the database, and display on the internet. 我的所有代码都可以从Gmail提取电子邮件,插入数据库并在Internet上显示。
The problem I am having is that when displaying the HTML emails on the website, the HTML inherits all sorts of CSS class, et al. 我遇到的问题是,当在网站上显示HTML电子邮件时,HTML会继承各种CSS类,等等。 definitions in place on the page and ruins the formatting of the original email.
页面上的定义不正确,并破坏了原始电子邮件的格式。 For example, a simple bulleted list from the email takes on a background color and specialized font.
例如,电子邮件中的一个简单的项目符号列表具有背景色和专用字体。 I have experimented with wkhtmltopdf to preserve formatting fidelity, but the customer wants the raw email on the page in it's original formatting rather than a linked PDF.
我已经尝试过使用wkhtmltopdf来保留格式保真度,但是客户希望页面上的原始电子邮件以其原始格式而不是链接的PDF。
Is there a way I can discard all inherited formatting and display the HTML email to the web page in it's original formatting? 有什么方法可以丢弃所有继承的格式,并以原始格式将HTML电子邮件显示到网页上?
You can display the email in an iframe. 您可以在iframe中显示电子邮件。
The iframe doesn't inherit the CSS from the calling parent, so your email is displayed with a clean css sheet. iframe不会从调用父级继承CSS,因此您的电子邮件将以干净的CSS表显示。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.