Answers.Body: <p>There is a good, baked-in solution for this now. Thanks to work by Coleman:</p>
  
  <p>You can add the fullPage = true setting to the CKEditor configuration just for CiviMail in:</p>
  
  <p>Administer > Customize Data and Screens > Display Preferences > Configure CKEditor > CiviMail tab > Advanced options > Set fullPage = true as an option.</p>
  
  <p>Source:
  <a href="https://github.com/civicrm/civicrm-core/pull/9419#issuecomment-261834710" rel="nofollow noreferrer">https://github.com/civicrm/civicrm-core/pull/9419#issuecomment-261834710</a></p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2016-12-16T08:49:06.393Z
Answers.LastActivityDate: 2016-12-16T08:49:06.393Z
Answers.UserDisplayName: John
Answers.Body: <p>Not a good solution but what you can do is disable Advanced Content Filter (ACF) in ckeditor by editing the config.js file in the ckeditor folder like this:</p>
  
  <pre><code>config.allowedContent = true;
  </code></pre>
  
  <p>See <a href="http://docs.ckeditor.com/#!/guide/dev_allowed_content_rules" rel="nofollow">documentation</a> for more info.</p>
  
  <p>What I do is extend the ACF like this:</p>
  
  <pre><code>config.extraAllowedContent = 'html;head;body;span;ul;li;table;td;style;*[id];*(*);*{*}';
  
  [ ] // for attributes
  
  { } // for styles
  
  ( ) // for classes
  </code></pre>
  
  <p>That way you prevent ckeditor from striping html, body, head, id's or any element tag or even attributes that you need, but it won't add the default html->head->body by default (the behaviour with fullPage = true). The downside is that you will have to add the line on each CiviCRM upgrade, and i don't belive it will work with header/footer templates, I haven't tried it though.</p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-08-11T20:41:49.730Z
Answers.Text: Thanks @John, for me looks like the easiest solution until CiviCRM 4.7 is released, where is seems like (as Coleman says in the mentioned post) we will be able to configure those options as needed.
Answers.UserDisplayName: Andrei
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2016-10-13T20:44:23.067Z
Answers.Text: I'm no expert on this, but it looks like this solution might be a bit unsafe. I'm not sure that it takes into account this: http://docs.ckeditor.com/#!/guide/dev_disallowed_content, heading 'How to allow everything except...', which says that if  ACF is turned off then disallowed content is turned off too. I tried the above with disallowed content including 'script' and scripts were not disabled. In contrast, the solution in the link I mentioned gives control over what is disallowed. But maybe I'm wrong! Feel free to put me right if I've missed something.
Answers.UserDisplayName: Andyg8
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2016-10-14T09:04:21.197Z
Answers.Text: @Andyg8 you are correct, turning off ACF will turn off also disallowed content, what I was trying to say is that you either turn off ACF entirely or you specify what tags are allowed extending the default ACF settings with `extraAllowedContent`, so you could add the `script` tag to `extraAllowedContent` while ACF is still on, makes sense?
Answers.UserDisplayName: Andrei
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2016-10-14T20:09:05.280Z
Answers.Text: Ahh, that makes total sense. Somehow I missed that you were talking about two alternative options, and I applied both bits of code. I've learnt a lot from this experience. Thanks!
Answers.UserDisplayName: Andyg8
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-11-20T18:27:05.057Z
Answers.Text: @Andrei .. Where is that post where Coleman says this is configurable in 4.7 ?
Answers.UserDisplayName: commonpike
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-11-21T09:54:54.323Z
Answers.Text: @commonpike this is the post https://civicrm.org/blog/colemanw/big-changes-to-wysiwyg-editing-in-47
Answers.UserDisplayName: Andrei
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-08-10T23:07:36.483Z
Answers.LastActivityDate: 2015-08-10T23:15:58.400Z
Answers.LastEditDate: 2015-08-10T23:15:58.400Z
Answers.UserDisplayName: Andrei
Answers.Body: <p>Another option: <strong>Don't use those tags in your email.</strong></p>
  
  <p>If you actually need a <code>&lt;title&gt;</code> in your email, sure, this isn't for you. </p>
  
  <p>For the majority of cases, it's unlikely those top-level tags actually are required elements in the email content or design.</p>
  
  <p>By replacing them with regular block-level elements like <code>&lt;div&gt;</code>, and updating the CSS to reflect these changes, you may find this sort of workaround isn't necessary at all. </p>
  
  <p>That can keep things much simpler.</p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-04-04T05:15:28.607Z
Answers.LastActivityDate: 2017-04-04T05:15:28.607Z
Answers.UserDisplayName: Chris Burgess
Answers.Body: <p>Can you add your custom email template to Civicrm Administer/Communication/ Message Templates (Add Message Template)? Then you can edit/paste in your tags such as  ,  in the HTML section ( assuming you would be able to send the mail from civicrm, I don't know your context)</p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-08-10T08:03:13.457Z
Answers.Text: Hi Lesley, the message template also strips out the html, head and body tags because we are using the CKEditor, as mentioned in the question. CiviCRM strips these tags out of the custom header/footer as well.
Answers.UserDisplayName: John
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-08-10T18:26:52.837Z
Answers.Text: I meant can you edit the Civi Templates without using CKEditor?
Answers.UserDisplayName: Lesley Evensen
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-08-11T15:36:56.967Z
Answers.Text: Ah I see. This would be possible, but we want to keep the editing exprience as easy as possible for admins. Ideally they could just load up th template and edit what they need to in the WYSIWYG then send the email :] Thanks for the suggestion.
Answers.UserDisplayName: John
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-08-12T16:17:25.993Z
Answers.Text: @LesleyEvensen Been trying this.  See related question (not about CKEDITOR specifically) http://civicrm.stackexchange.com/questions/4671/coding-of-civimail-header-body-and-footer-best-practice
Answers.UserDisplayName: Sonicthoughts
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-08-07T22:46:25.000Z
Answers.LastActivityDate: 2015-08-07T22:46:25.000Z
Answers.UserDisplayName: Lesley Evensen
Answers.Body: <p>Our temporary solution is to customise the crmUi.js file that defines the CKEditor configuration for the mailing HTML body. The patch file for this, if anyone's interested, can be found here: <a href="https://gist.github.com/JKingsnorth/d89fc355ee3d43d3adfc" rel="nofollow">https://gist.github.com/JKingsnorth/d89fc355ee3d43d3adfc</a></p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-08-10T11:00:14.757Z
Answers.LastActivityDate: 2015-08-10T11:00:14.757Z
Answers.UserDisplayName: John
Answers.Body: <p>Bit hacky, but you could try including the necessary text via a smarty include. <a href="http://wiki.civicrm.org/confluence/display/CRMDOC/Smarty+in+mail+templates" rel="nofollow">Turn on smarty for mail templates</a>, copy the content from your template into a .tpl file then put it in the templates directory (or in the templates folder in an extension). Then include in the visual editor with:</p>
  
  <p>{include file=CRM/membership.tpl} (or as appropriate)</p>
  
  <p>You'd need to edit this file manually, outside of Civi, but it should stop CKeditor messing about with the content.</p>
  
  <p>(FYI we had odd problems with the presence/non-presence of the $ sign in smarty tags when we included files like this, but that was a few versions ago so that bug may have been fixed by now.)</p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-08-10T08:04:56.860Z
Answers.Text: Could be a workaround, but I don't think this would be a very easy process for our email editors to follow. Would be a shame to have to circumnavigate the built-in tools. Thanks for the suggestion though.
Answers.UserDisplayName: John
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-08-08T15:30:43.383Z
Answers.LastActivityDate: 2015-08-08T15:30:43.383Z
Answers.UserDisplayName: Andrew West
Answers.Body: <p>We had the same problem on a multisite / Aegir system and after much work solved this. </p>
  
  <p>Our solution is detailed here: <a href="https://civicrm.stackexchange.com/questions/17355/is-this-a-bug-civicrm-files-variable/17470#17470">Solved: Is this a bug - [civicrm.files] variable</a></p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-03-01T10:07:18.770Z
Answers.LastActivityDate: 2017-03-01T10:07:18.770Z
Answers.LastEditDate: 2017-04-13T12:53:13.017Z
Answers.UserDisplayName: Davy Ivins
Body: <p>As a follow-up to: <a href="https://civicrm.stackexchange.com/questions/4523/how-do-i-override-the-default-ckeditor-configuration">How do I override the default CKEditor configuration?</a></p>
  <p><strong>The issue</strong></p>
  <p>We have a custom email template that uses <code>&lt;html&gt;</code>, <code>&lt;head&gt;</code>, <code>&lt;body&gt;</code>. When using either the CKEditor main 'email body' editor, or the standard textarea when creating a custom header/footer, these tags are stripped out.</p>
  <p>Is this a combination of CKEditor and CiviCRM both stripping out these tags separately?</p>
  <p><strong>I've tried...</strong></p>
  <p>I originally tried adding the CKEditor config option <code>fullPage=true</code> . This works, but automatically adds <code>&lt;html&gt;</code>, <code>&lt;head&gt;</code>, <code>&lt;body&gt;</code> to <em>every</em> CKEditor instance (cross-posted <a href="https://stackoverflow.com/questions/31879137/ckedtior-allow-html-head-body-without-using-fullpage-true">here</a>) .</p>
  <p>But then I spotted that the <code>&lt;html&gt;</code>, <code>&lt;head&gt;</code>, <code>&lt;body&gt;</code> tags are also stripped if used within header and footer templates, as described in this <a href="https://forum.civicrm.org/index.php?topic=30479.0" rel="nofollow noreferrer">forum post</a>. And these fields do not use CKEditor.</p>
  
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2015-08-07T18:13:56.657Z
Comments.Text: John - Would it be possible for you to clarify precisely why you need those tags included, as opposed to reworking your template?  That would be really helpful.
Comments.UserDisplayName: Lesley Carter - BackOffice
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2015-08-10T10:01:41.250Z
Comments.Text: We've tried reworking it, but can't seem to get the template working correctly in all the browsers, applications and devices we need to without these tags being present.
Comments.UserDisplayName: John
Tags: <civimail><tags><ckeditor>
Title: How can I use <html>, <head>, <body> tags in a mailing?
ThreadText: # How can I use <html>, <head>, <body> tags in a mailing?
  
  (Asked by: username_0 on 2015-08-07)
  
  As a follow-up to: [How do I override the default CKEditor configuration?](https://civicrm.stackexchange.com/questions/4523/how-do-i-override-the-default-ckeditor-configuration)
  
  **The issue**
  
  We have a custom email template that uses , , . When using either the CKEditor main 'email body' editor, or the standard textarea when creating a custom header/footer, these tags are stripped out.
  
  Is this a combination of CKEditor and CiviCRM both stripping out these tags separately?
  
  **I've tried...**
  
  I originally tried adding the CKEditor config option `fullPage=true` . This works, but automatically adds , ,  to *every* CKEditor instance (cross-posted [here](https://stackoverflow.com/questions/31879137/ckedtior-allow-html-head-body-without-using-fullpage-true)) .
  
  But then I spotted that the , ,  tags are also stripped if used within header and footer templates, as described in this [forum post](https://forum.civicrm.org/index.php?topic=30479.0). And these fields do not use CKEditor.
  
  **Tags:** civimail, tags, ckeditor
  
  > **Comments:**
  > **username_1**: username_0 - Would it be possible for you to clarify precisely why you need those tags included, as opposed to reworking your template?  That would be really helpful.  
  > **username_0**: We've tried reworking it, but can't seem to get the template working correctly in all the browsers, applications and devices we need to without these tags being present.  
  
  ---
  
  ## 7 answers
  
  ### Answer by username_0 on 2016-12-16. Score: 2 | Accepted answer
  
  There is a good, baked-in solution for this now. Thanks to work by Coleman:
  
  You can add the fullPage = true setting to the CKEditor configuration just for CiviMail in:
  
  Administer > Customize Data and Screens > Display Preferences > Configure CKEditor > CiviMail tab > Advanced options > Set fullPage = true as an option.
  
  Source:
  <https://github.com/civicrm/civicrm-core/pull/9419#issuecomment-261834710>
  
  
  ---
  
  ### Answer by username_2 on 2015-08-10. Score: 3
  
  Not a good solution but what you can do is disable Advanced Content Filter (ACF) in ckeditor by editing the config.js file in the ckeditor folder like this:
  config.allowedContent = true;
  
  See documentation for more info.
  What I do is extend the ACF like this:
  config.extraAllowedContent = 'html;head;body;span;ul;li;table;td;style;*[id];*(*);*{*}';
  
  [ ] // for attributes
  
  { } // for styles
  
  ( ) // for classes
  
  That way you prevent ckeditor from striping html, body, head, id's or any element tag or even attributes that you need, but it won't add the default html->head->body by default (the behaviour with fullPage = true). The downside is that you will have to add the line on each CiviCRM upgrade, and i don't belive it will work with header/footer templates, I haven't tried it though.
  
  > **Comments:**
  > **username_2**: Thanks @username_0, for me looks like the easiest solution until CiviCRM 4.7 is released, where is seems like (as Coleman says in the mentioned post) we will be able to configure those options as needed.  
  > **username_3**: I'm no expert on this, but it looks like this solution might be a bit unsafe. I'm not sure that it takes into account this: http://docs.ckeditor.com/#!/guide/dev_disallowed_content, heading 'How to allow everything except...', which says that if  ACF is turned off then disallowed content is turned off too. I tried the above with disallowed content including 'script' and scripts were not disabled. In contrast, the solution in the link I mentioned gives control over what is disallowed. But maybe I'm wrong! Feel free to put me right if I've missed something.  
  > **username_2**: @username_3 you are correct, turning off ACF will turn off also disallowed content, what I was trying to say is that you either turn off ACF entirely or you specify what tags are allowed extending the default ACF settings with `extraAllowedContent`, so you could add the `script` tag to `extraAllowedContent` while ACF is still on, makes sense?  
  > **username_3**: Ahh, that makes total sense. Somehow I missed that you were talking about two alternative options, and I applied both bits of code. I've learnt a lot from this experience. Thanks!  
  > **username_4**: @username_2 .. Where is that post where Coleman says this is configurable in 4.7 ?  
  > **username_2**: @username_4 this is the post https://civicrm.org/blog/colemanw/big-changes-to-wysiwyg-editing-in-47  
  
  ---
  
  ### Answer by username_5 on 2017-04-04. Score: 2
  
  Another option: **Don't use those tags in your email.**
  
  If you actually need a  in your email, sure, this isn't for you.
  
  For the majority of cases, it's unlikely those top-level tags actually are required elements in the email content or design.
  
  By replacing them with regular block-level elements like , and updating the CSS to reflect these changes, you may find this sort of workaround isn't necessary at all.
  
  That can keep things much simpler.
  
  
  ---
  
  ### Answer by username_6 on 2015-08-07. Score: 1
  
  Can you add your custom email template to Civicrm Administer/Communication/ Message Templates (Add Message Template)? Then you can edit/paste in your tags such as , in the HTML section ( assuming you would be able to send the mail from civicrm, I don't know your context)
  
  > **Comments:**
  > **username_0**: Hi Lesley, the message template also strips out the html, head and body tags because we are using the CKEditor, as mentioned in the question. CiviCRM strips these tags out of the custom header/footer as well.  
  > **username_6**: I meant can you edit the Civi Templates without using CKEditor?  
  > **username_0**: Ah I see. This would be possible, but we want to keep the editing exprience as easy as possible for admins. Ideally they could just load up th template and edit what they need to in the WYSIWYG then send the email :] Thanks for the suggestion.  
  > **username_7**: @LesleyEvensen Been trying this.  See related question (not about CKEDITOR specifically) http://civicrm.stackexchange.com/questions/4671/coding-of-civimail-header-body-and-footer-best-practice  
  
  ---
  
  ### Answer by username_0 on 2015-08-10. Score: 1
  
  Our temporary solution is to customise the crmUi.js file that defines the CKEditor configuration for the mailing HTML body. The patch file for this, if anyone's interested, can be found here: <https://gist.github.com/JKingsnorth/d89fc355ee3d43d3adfc>
  
  
  ---
  
  ### Answer by username_8 on 2015-08-08. Score: 1
  
  Bit hacky, but you could try including the necessary text via a smarty include. [Turn on smarty for mail templates](http://wiki.civicrm.org/confluence/display/CRMDOC/Smarty+in+mail+templates), copy the content from your template into a .tpl file then put it in the templates directory (or in the templates folder in an extension). Then include in the visual editor with:
  
  {include file=CRM/membership.tpl} (or as appropriate)
  
  You'd need to edit this file manually, outside of Civi, but it should stop CKeditor messing about with the content.
  
  (FYI we had odd problems with the presence/non-presence of the $ sign in smarty tags when we included files like this, but that was a few versions ago so that bug may have been fixed by now.)
  
  > **Comments:**
  > **username_0**: Could be a workaround, but I don't think this would be a very easy process for our email editors to follow. Would be a shame to have to circumnavigate the built-in tools. Thanks for the suggestion though.  
  
  ---
  
  ### Answer by username_9 on 2017-03-01. Score: 0
  
  We had the same problem on a multisite / Aegir system and after much work solved this.
  
  Our solution is detailed here: [Solved: Is this a bug - [civicrm.files] variable](https://civicrm.stackexchange.com/questions/17355/is-this-a-bug-civicrm-files-variable/17470#17470)
  
  
  ---
  
  