Looking for more information on how to do PHP the right way? Check out PHP: The Right Way

Sylius Blog:
Sending configurable e-mails in Symfony
Oct 05, 2015 @ 16:15:46

In a post to the Sylius blog Mateusz Zalewski shows you how to create configurable emails in your Symfony-based application with help from a custom bundle they've released to help make it a much simpler process.

Every developer, during their adventure with PHP programming has been struggling with sending emails in a web application. However using PHP send() function is often insufficient for common web applications, when you need templates, variables, configurations etc.Fortunately, Sylius provides SyliusMailerBundle and Mailer component, with some awesome features. [...] Of course, this bundle and component are fully decoupled and can be used in any Symfony application.

They walk you through the installation (via Composer) and configuration of the bundle, adding it's dependencies to the kernel of your application. He shows how to configure the container with connection information (like the name and from values) and update your database with the tool's migrations. From there he shows how to customize your emails, making use of the Twig template handling to define the body contents. The bundle also makes it possible to define custom email types with different settings for each. Finally they show how to send the emails, grabbing the sender information and sending the email, either more manually or via a custom defined email type.

tagged: symfony email configurable tutorial bundle customize template sender

Link: http://sylius.org/blog/sending-configurable-e-mails-in-symfony


Trending Topics: