PHP code example of leuffen / template-mailer

1. Go to this page and download the library: Download leuffen/template-mailer 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/ */

    

leuffen / template-mailer example snippets


$parser = new MailTemplateParser();
$parser->loadTemplate($template);
$parser->send ($orderData);

$parser = new MailTemplateParser();
$parser->loadTemplate ($template);
$mail = $parser->apply($orderData);

$mail->addPart(new FileAttachment("path/to/image.jpg"));

$mail->addPart(
    $_part = new MailBody(
        chunk_split(
            base64_encode(
                file_get_contents($fileName)
                ),
                75
            ),    
        mime_content_type($fileName),
        "UTF-8",
        "base64"
    )
);
$_part->setContentDispositionFileName(basename($fileName));

$mail->send();

$mailBody = new MailBody ("[email protected]", "Some subject", "[email protected]");
$mailBody->addPart (new MailPart ("Some Text Content", "text/plain"));
$mailBody->addPart (new MailPart ("<h1>Some Html Part</h1>", "text/html"));
$mailBody->send();

{= __CONTEXT__ | raw } 

$mailTemplateParser->getTextTemplateParser()->addFilter("price", function ($input) { return number_format($input) });