Good all the time of day.
The task was to write a utility for sending letters. There is no problem with the utility itself. There are problems with the layout of letters.
As you know, HTML layout of the letter itself is not a trivial thing, since it differs from the usual HTML layout of ordinary pages in terms of supporting various features.
The biggest problem is the lack of support for <style>
in <head>
for GMail (more here ). Those. as you understand, you cannot jot down common CSS styles for elements by selectors. These styles should be assigned to each element through the style=""
attribute.
Very cool, this problem is solved at mailchimp.com . They have a built-in parser that parses the <style>
and hangs styles to the corresponding elements. Those. Here is a letter:
... <style> a { color: green; } a.someLink { color: red; } </style> ... <body> ... <a class="someLink">first</a> <a class="anotherClass">second</a> <a>third</a> ...
Converted to the form:
... <style> a { color: green; } a.someLink { color: red; } </style> ... <body> ... <a class="someLink" style="color: red;">first</a> <a class="anotherClass" style="color: green;">second</a> <a style="color: green;">third</a> ...
This is very cool, and this is what we need to achieve. The bottom line is that the letter has a stylized template and it is assumed that its content letters are edited using a WYSIWYG editor. Those. The content of the letter is obtained in the form of HTML, but due to the lack of support for the <style>
, the content is not formatted according to the style of the template itself.
The most ideal option is to find some kind of tool with which to do the same thing that mailchimp does. Those. some kind of DOM and CSS parser that gives the DOM with hung styles. Maybe someone knows about something similar?
PS: ideally, of course, in PHP :)