1. Go to this page and download the library: Download schvoy/mail-template-bundle 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/ */
schvoy / mail-template-bundle example snippets
declare(strict_types=1);
namespace App\Mails;
use Schvoy\MailTemplateBundle\Mailer\AbstractMailType;
use Schvoy\MailTemplateBundle\Mailer\Engine\TwigBased;
class TwigBasedEmail extends AbstractMailType
{
use TwigBased;
protected string $key = 'first_email.test';
}
declare(strict_types=1);
namespace App\Mails;
use Schvoy\MailTemplateBundle\Mailer\AbstractMailType;
use Schvoy\MailTemplateBundle\Mailer\Engine\DoctrineBased;
class DoctrineBasedEmail extends AbstractMailType
{
use DoctrineBased;
protected string $key = 'test_email';
}
use Schvoy\MailTemplateBundle\Mailer\Configuration;
use Symfony\Component\Mime\Email;
$testMail = $mailSender->getMailType(TwigBasedEmail::class);
// $testMail = $mailSender->getMailType(DoctrineBasedEmail::class);
$mailSender->send(
$testMail,
[
new Recipient('[email protected]', 'Test user'),
new Recipient('[email protected]'),
new Recipient('[email protected]', cc: true),
new Recipient('[email protected]', bcc: true),
],
extendConfiguration: function (Configuration $configuration) {
// Optional callback function to extend configuration before create email
$configuration->addParameter('_ctaLink_', 'https://example.com');
},
extendEmail: function (Email $email) {
// Optional callback function to extend email before send
// Here you can also add attachments based on your needs
}
);
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.