paulbunyannet / premailer
Css inliner for HTML emails
Installs: 10 660
Dependents: 2
Suggesters: 0
Security: 0
Stars: 2
Watchers: 5
Forks: 2
Open Issues: 2
Requires
- php: ^7.0 | ^8.0
- fakerphp/faker: ^1.12.0
- guzzlehttp/guzzle: ^7.2
- voku/css-to-inline-styles: ^2.0
Requires (Dev)
- phpunit/phpunit: ^9.5.0
This package is auto-updated.
Last update: 2024-11-19 23:36:01 UTC
README
Inline CSS for use in html emails, uses Dialect Preflight API
install
composer require paulbunyannet/premailer:"^1.0"
Usage
From String
To inline css for a html email from a string:
<?php
require_once 'vendor/autoload.php';
$html = '<html>
<head>
<style>
.paragraph {
font-size: 12px;
}
</style>
</head>
<body>
<p class="paragraph">Lorem ipsum dolor sit amet, ne sea sumo laudem. Iracundia concludaturque no pro. Ex tempor praesent eos, ea dicta consetetur ius, eligendi posidonium referrentur cum no. Nulla dissentiet vel et, mei at sumo numquam, pro iriure constituam voluptatibus te. Affert fabulas impedit nec an, aeterno partiendo voluptaria duo ne.</p>
</body>
</html>';
$inlined = Premailer::html($html);
This will result in the .paragraph class attributes being injected into the paragraph tag it's used in.
From a url
<?php
require_once 'vendor/autoload.php';
$url = 'https://google.com';
$inlined = Premailer::url($url);
Response
Both responses will return keys "html", the html string with inlined css, and "plain", a plain text version of the html provided, on success or exception on error.