7

Is there a tool or a bundle in Symfony2 that allows me to create normal templates with css files, and then on the fly convert it to inline css rules so it can be used as the body of an email?

3 Answers 3

4

I know of three tools that can do this and which you can use in Symfony:

  • Premailer is an online tool which provides this service. It has an API and a php wrapper for that API
  • CssToInlineClass is a php class that offers this functionality
  • Mailchimp offers a function in their api that offers this functionality

The first two don´t have a direct symfony implementation, though they will be easy to use. For mailchimp, there is a mailchimp bundle which offers this functionality, though the bundle is not very well documented.

Sign up to request clarification or add additional context in comments.

4 Comments

Thanks, CssToInlineClass looks like the way to go for me
Maybe you can create a public bundle for that class and share it with everyone :-)
haha it will be very nice but first I have to learn how to create a bundle for sharing in github. But I will keep it in mind.
These is a Symfony 2 bundle to be found here: packagist.org/packages/robertotru/to-inline-style-email-bundle as mentioned in one of the answers by @JeanValjean
4

Today I discovered through another question that exists such a Symfony2 bundle that fits your needs (I didn't tested it).

You can use ToInlineStyleEmailBundle, it embeds the CSSToInline library that Carlos Granados suggested in his answer.

With this Symfony2 bundle you can get the converter as a service ($this->get('css_to_inline_email_converter')) and then use it for your needs. It also supports templates generations.

Comments

2

I've had great results with integrating the Emogrifier PHP class within CakePHP. Inlines all styles very nicely. Not sure if it has a Symfony bundle but shouldn't be hard to integrate.

https://github.com/jjriv/emogrifier

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.