Sending multipart email from a Task in symfony 1.4

I recently needed to send the result of an action in symfony via email daily. E-mail has changed slightly in symfony 1.3/1.4 – here’s how I did it. I really don’t like my solution at all, the use of get_partial() from within a Task seems very wrong to me – but I’m in a rush so it will do for now, I’d love to hear feedback

The mail has a plain text, and HTML part to it. It generates the contents of the mail by rendering a partial, which requires a context to be set up. I modify sf_format by changing the request format on the request.

4 thoughts on “Sending multipart email from a Task in symfony 1.4”

  1. Just to make it clear. You MUST set the application name in the options as this isn’t by default and will cause $this->configuration to be an instance of ProjectConfiguration not ApplicationConfiguration.

  2. Thanks for your piece of code, it helped me.

    By the way, I got warnings when instanciating the context object. It said that the headers were already sent. The problem is that the context instanciation makes a call to session_start, which sends headers to the client. So if you have any output before context instanciation, like log messages (my case), you’ll get these warnings.

    The solution is to instanciate the context object at the beginning of the task, before any output.

    Thanks again.

  3. @ian: thanks for the post, very helpful and well referenced

    @Harry: funny to find you back here. Your comment was key to understand the problem I was just having, not loading the correct parameters. Thanks 🙂

Leave a Reply

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