Engine Package
Transform
Transform HTML emails for specific email clients with per-client CSS rewriting.
transformForAllClients
Transforms HTML for all 10 supported email clients.
function transformForAllClients(html: string): TransformResult[]Parameters
| Parameter | Type | Description |
|---|---|---|
html | string | The email HTML source code |
Returns
An array of TransformResult objects, one per client:
interface TransformResult {
clientId: string; // e.g. "gmail-web"
html: string; // Transformed HTML for this client
warnings: CSSWarning[]; // Warnings specific to this transform
}Example
import { transformForAllClients } from "@emailens/engine";
const results = transformForAllClients(emailHtml);
for (const result of results) {
console.log(`${result.clientId}: ${result.warnings.length} warnings`);
// Write transformed HTML to file, render in iframe, etc.
}transformForClient
Transform HTML for a single email client.
function transformForClient(html: string, clientId: string): TransformResultParameters
| Parameter | Type | Description |
|---|---|---|
html | string | The email HTML source code |
clientId | string | Client ID (e.g. "gmail-web", "outlook-windows", "outlook-windows-legacy") |
Example
import { transformForClient } from "@emailens/engine";
const result = transformForClient(emailHtml, "outlook-windows-legacy");
console.log(result.html); // HTML rewritten for Outlook Classic (Word engine)What transforms do
Transforms rewrite CSS for each client's rendering engine:
- Style inlining — moves
<style>block rules to inlinestyleattributes (for Gmail) - Property removal — strips CSS properties the client doesn't support
- Fallback insertion — adds client-specific fallbacks (e.g., VML for Outlook)
- Value conversion — adjusts units and values for client compatibility
- Media query handling — removes or adjusts media queries based on client support