Search code examples
yii2yii2-basic-app

Is it possible to add BoostrapCSS classes on an email layout?


I'm trying to make a digest e-mail to be sent by crontab using yii/console.

I can manage to send the email already but the layout is not as good because I can't load the bootstrap files needed to use it's classes.

Is it possible to use bootstrap css classes on an email using yii2?


Solution

  • First some background: What email clients are the intended recipients using? If it's browser-based, you're going to run into consistency issues with what, say Google or Microsoft, allow as far as the contents of the email, e.g. stripping out <script> blocks and such. IIRC, the use of inline styles is STRONGLY recommended. This is an older article, but many of the tenants still apply.

    To answer your question, it may not be worth it for Bootstrap given the size of the CSS - but if you can make it inline styles instead of classes, it may work. I should also add that unless the development framework specifically adds for a use case like this, I don't think it matters if it's yii or anything else.