svb / mailing
Enable third party mailing via connectors that provide api access for sending templated e-mails
Installs: 28
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 1
Forks: 0
Open Issues: 0
Type:symfony-bundle
Requires
- ext-json: *
- doctrine/dbal: ^2.0|^3.0
- mailjet/mailjet-apiv3-php: ^1.0
- symfony/config: ^3.4|^4.3
- symfony/console: ^4.0|^5.0
- symfony/dependency-injection: ^3.4|^4.3
- symfony/http-kernel: ^3.4|^4.3
Requires (Dev)
- mockery/mockery: ^1.4
- phpunit/phpunit: ^9.5
This package is auto-updated.
Last update: 2025-04-29 01:11:40 UTC
README
This bundle has been developed in order to send mails from multiple systems without writing a single line of html nor care about any localizations.
How to install/configure
composer require svb/mailing
- Make sure the bundle is correctly registered in either
config/bundles.php
(sf4/5) orapp/AppKernel.php:registerBundles
(sf3) - Add a configuration for the bundle like this:
svb_mailing: tries_count: 5 # number of resend tries of a mail before the delivery is set to failed (default 5) database: url: 'mysql://root:root@mysql/svb_mailing' connectors: # see connectors config
How to use
- Inject the service
svb_mailing.mailer
(SVB\Mailing\Mailer when using the sf auto wiring) - Create one or more mail objects using one of the many mail templates located within the namespace
SVB\Mailing\Mail\
- Pass your object(s) into the sendMails method of the
svb_mailing.mailer
service - You mail should either been sent, or you should have got an exception what to do
Adding Mail Templates
- Create a new class implementing MailInterface (AbstractMail to make your life a bit easier)
Hint: Mail Templates do not necessarily need to be in one folder, use sub directories to order them! - Add the template to the parameter "svb_mailing.mail_identifiers" (identifier string => fully qualified classname)
Pro tip: Definitely consider creating a reusable bundle for your templates, that way you can use your templates across all projects!
Asynchronous resending of failed messages
Since most provider handle sent messages using message queues, most responses for a "send" request will return "200 OK".
The mailing bundle provides easy functionality for checking message states and resending failed messages using a database
to store all messages and their states. Since the worker for this needs to be executed asynchronously, we implemented a
symfony command for this: bin/console svb:mailing:worker
. Make sure this command is executed at least once every hour
(the more frequent it's executed the better!) to ensure your mails getting resent, and the states are updated correctly.