News Feed
Sections




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

Gonzalo Ayuso:
Sending automated emails with PHP, Swiftmailer and Twig
September 24, 2013 @ 11:40:57

Gonzalo Ayuso has posted a new tutorial today showing you how to combine PHP, Swiftmailer and Twig to send automated emails from your application.

My work as host is basically pick the place and encourage people to join to the Coding Dojo. One way of doing this (besides twitter buzz) is take my address book and send one bulk email to all of them inviting to join us. I don't like this kind of mails. They look like spam, so I prefer to send a personalized email. This email has a common part (the place location, the hour, the event description, ...) and the personalized part. I can do it manually, the list isn't so huge, but definitely that's not cool. Because of that I have done a little script to perform this operation.

His example extracts the information from a simple spreadsheet exported as a CSV file. He creates a simple Mailer class that uses Swiftmailer to do the actual sending. You pass in the Twig rendering object (Twig_Environment) that's used to render the email output. He includes a "Spammer" class that uses the Symfony EventDispatcher to send the email if everything works or an error email if something fails. He then drops it all into a Symfony Console command structure, defines several configuration settings in a "config.yml" and makes the script to execute the commands.

0 comments voice your opinion now!
email swiftmailer twig template tutorial symfony console eventdispatcher

Link: http://gonzalo123.com/2013/09/23/sending-automated-emails-with-php-swiftmailer-and-twig

blog comments powered by Disqus

Similar Posts

PHPMaster.com: Better Understanding Random

Stefan Mischook's Blog: Setting up an MVC structure with the Zend Framework - part 2

Spindrop.us: Digg-style AJAX comment editing in PHP/symfony

Matthew Weier O'Phinney's Blog: Autocompletion with Zend Framework and Dojo

Gonzalo Ayuso: Bundles in Silex using Stack


Community Events

Don't see your event here?
Let us know!


release example podcast version introduction laravel voicesoftheelephpant community opinion library conference symfony2 extension framework api series performance php7 interview application

All content copyright, 2015 PHPDeveloper.org :: info@phpdeveloper.org - Powered by the Solar PHP Framework