PHP code example of bummzack / swiftmailer-emogrifyplugin

1. Go to this page and download the library: Download bummzack/swiftmailer-emogrifyplugin library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

bummzack / swiftmailer-emogrifyplugin example snippets


$plugin = new EmogrifierPlugin();
$plugin->setCss('.customStyle: { color: red; };');

$plugin = new Bummzack\SwiftMailer\EmogrifyPlugin\EmogrifierPlugin();
$emogrifier->setCss(file_get_contents( /* path to your CSS file */ ));

// Create the Mailer using any Transport
$mailer = new Swift_Mailer(
    new Swift_SmtpTransport('smtp.example.org', 25)
);

// Use Emogrifier plugin to inline styles.
$mailer->registerPlugin($plugin);

$message = new Swift_Message();
$message
    ->setSubject('Your subject')
    ->setFrom(['[email protected]' => 'Test'])
    ->setTo(['[email protected]'])
    ->setBody('<p>My custom HTML</p>', 'text/html');

// Send your email
$mailer->send($message);