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

Daniel Cousineau: Using Symfony Console From Scratch

PHPBuilder.com: AJAX and PHP Part 4 - Forms and JavaScript Limitations

Sameer Borate: Efficiently Replicating RETS data to MySQL

ServerGrove Blog: Deployment of Symfony2 applications with Ansible

PHPBuilder.com: Using XML, Part 5 - SOAP and WSDL


Community Events





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


bugfix laravel language introduction threedevsandamaybe series interview list api developer configure install community symfony podcast library application code wordpress release

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