Sending emails from a task in Symfony 1.4

Sending emails from a task seems like it would be a pretty common, and therefore straightforward task (automated from a cron job for example), but in Symfony its not exactly trivial.

The main reason is that you don’t have a context set from the task, and if you create one it doesn’t know the domain to use when you generate absolute url’s. If you follow Symfony’s Documentation and add a host to the context of your routes, sfDoctrineRoute’s stopped working for me.

While I don’t like tying routing to my models, the solution at http://snippets.symfony-project.org/snippet/378 worked for me. Just watch out for the following erroneous line:
'is_secure' => sfConfig::get('app_host', false),

Posted in Tech Tagged with: , ,

Leave a Reply

Your email address will not be published. Required fields are marked *

*