synolia / sylius-mail-tester-plugin
Mail Tester Plugin.
Installs: 104 949
Dependents: 2
Suggesters: 0
Security: 0
Stars: 13
Watchers: 13
Forks: 7
Open Issues: 0
Type:sylius-plugin
Requires
- php: ^8.0
- fakerphp/faker: ^1.10
- sylius/sylius: ^1.10
- symfony/framework-bundle: ^5.4|^6.0
- symfony/service-contracts: ^1.1|^2.0|^3.0
- webmozart/assert: ^1.8
Requires (Dev)
- behat/behat: 3.12.0
- behat/mink-selenium2-driver: 1.6.0
- dmore/behat-chrome-extension: 1.4.0
- dmore/chrome-mink-driver: 2.9.0
- friends-of-behat/mink: 1.10.0
- friends-of-behat/mink-browserkit-driver: 1.6.1
- friends-of-behat/mink-debug-extension: 2.1.0
- friends-of-behat/mink-extension: 2.7.2
- friends-of-behat/page-object-extension: 0.3.2
- friends-of-behat/symfony-extension: 2.4.0
- friends-of-behat/variadic-extension: 1.5.0
- friendsoftwig/twigcs: 6.0.0
- j13k/yaml-lint: 1.1.4
- php-parallel-lint/php-parallel-lint: 1.3.2
- phpmd/phpmd: 2.13.0
- phpro/grumphp: 1.15.0
- phpspec/phpspec: 7.3.0
- phpstan/extension-installer: 1.2.0
- phpstan/phpstan: 1.9.6
- phpstan/phpstan-doctrine: 1.3.28
- phpstan/phpstan-phpunit: 1.3.3
- phpstan/phpstan-strict-rules: 1.4.4
- phpstan/phpstan-webmozart-assert: 1.2.2
- phpunit/phpunit: 9.5.27
- povils/phpmnd: 3.0.1
- rector/rector: ^0.15.2
- sebastian/phpcpd: 6.0.3
- seld/jsonlint: 1.9.0
- sylius-labs/coding-standard: 4.3.0
- symfony/browser-kit: 6.0.11
- symfony/debug-bundle: 6.0.11
- symfony/dotenv: 6.0.5
- symfony/lock: 6.0.15
- symfony/web-profiler-bundle: 6.0.17
- symfony/web-server-bundle: 4.4.44
README
Mail Tester Plugin
Test how your emails are rendered by sending them to your email from your Sylius admin panel.
Features
- See a list of all sylius emails
- Send example email one by one to your email address
- Send all example emails to your email address
- For each email, you have to select the entity to be used in the template.
Requirements
Installation
-
Add the bundle and dependencies in your composer.json :
$ composer require synolia/sylius-mail-tester-plugin
-
Enable the plugin in your
config/bundles.php
file by addSynolia\SyliusMailTesterPlugin\SynoliaSyliusMailTesterPlugin::class => ['all' => true],
-
Create a new file
config/routes/mailtester.yaml
with:synolia_mail_tester: resource: "@SynoliaSyliusMailTesterPlugin/Resources/config/admin_routing.yaml" prefix: '/%sylius_admin.path_name%'
Usage
- Log into admin panel
- Click on
Mail tester
in the Configuration section in main menu - Enter the email address that will receive the example email template
- Select the email you would like to be sent.
- Click on
Choose subject
- Fill empty boxes and select your entities.
- Click the Submit button.
Allow sending your custom emails
In order to be able to send a custom email with variables, you have to add a form type that will add those variables to the form. The important part is that your Form Type must implement ResolvableFormTypeInterface in order to be discovered by our FormTypeResolver.
<?php declare(strict_types=1); namespace Synolia\SyliusMailTesterPlugin\Form\Type; use Sylius\Component\Core\Model\Order; use Symfony\Bridge\Doctrine\Form\Type\EntityType; use Symfony\Component\Form\AbstractType; use Symfony\Component\Form\FormBuilderInterface; use Synolia\SyliusMailTesterPlugin\Resolver\ResolvableFormTypeInterface; public class CustomEmailType extends AbstractType implements ResolvableFormTypeInterface { /** @var string */ private const SYLIUS_EMAIL_KEY = 'custom_email'; //this should match your email identification key in sylius_mailer.yaml. public function buildForm(FormBuilderInterface $builder, array $options): void { parent::buildForm($builder, $options); /** * The key 'order' represent the name of the variable in your template. * Then you specify the type of the variable. * In this example we provide a list of all available orders. */ $builder->add('order', EntityType::class, [ 'class' => Order::class, 'choice_label' => 'number', ]); } public function support(string $emailKey): bool { return $emailKey === self::SYLIUS_EMAIL_KEY; } public function getCode(): string { return self::SYLIUS_EMAIL_KEY; } public function getFormType(string $emailKey): ResolvableFormTypeInterface { return $this; } }
Development
See How to contribute.
License
This library is under the MIT license.
Credits
Developed by Synolia.