Problem/Motivation

It would be useful to add an extra template that wraps all outgoing emails. This allows adding a header or footer, and adding classes based on the email type/sub-type to support theming.

Proposed resolution

Create a new EmailAdjuster for this purpose.

  • Option: plain. Send as plain text only.
  • Option: swiftmailer. Use the swiftmailer template and library scheme instead of the one from this module. This is intended as a short-term workaround and you should migrate to the new template when possible.

Create a new template email-wrap.

Remaining tasks

User interface changes

API changes

Data model changes

Comments

AdamPS created an issue. See original summary.

jwilson3’s picture

+1 I'd rather have a way to explicitly render the same template (or a different template) for text only versions, in order to have more control to exclude html or other elements for a plaintext version.

adamps’s picture

Status: Active » Needs review
StatusFileSize
new11.54 KB

Status: Needs review » Needs work

The last submitted patch, 3: symfony_mailer.wrap_.3271797-3.patch, failed testing. View results
- codesniffer_fixes.patch Interdiff of automated coding standards fixes only.

adamps’s picture

Status: Needs work » Needs review
StatusFileSize
new12.05 KB
new405 bytes
adamps’s picture

Issue summary: View changes
adamps’s picture

adamps’s picture

adamps’s picture

Issue summary: View changes
adamps’s picture

Status: Needs review » Fixed

  • AdamPS committed a8c1a17 on 1.x
    Issue #3271797 by AdamPS: Wrap email body
    
adamps’s picture

Issue summary: View changes
Status: Fixed » Needs review
StatusFileSize
new4.49 KB

After more evaluation:
- the rewrap option makes no sense as it's likely actually slower to add all the HTML then remove it again and it's hard to understand
- it's inefficient to wrap the HTML then remove it straight after - add a new option 'plain' instead of the PlainOnlyEmailAdjuster.

  • AdamPS committed bd60022 on 1.x
    Issue #3271797 by AdamPS: Wrap email body
    
adamps’s picture

Status: Needs review » Fixed
featuriz’s picture

After update to 1.1.0-beta2 my mail stopped entire styling. It breaks.
I was already doing something like following,

My file name is: email--contact-form--mail--contact-us.html.twig // This name was working before this update.

{% extends directory ~ '/templates/mail/email_template.html.twig' %}
{% block content %}
	{% include(directory ~ '/templates/mail/_body.html.twig') %}
{% endblock %}


email_template.html.twig:
- Contains all header footer extras.
_body.html.twig: - Contains the following code,

<table align="center" border="0" cellpadding="0" cellspacing="0" class="row-content stack" role="presentation" style="mso-table-lspace: 0pt; mso-table-rspace: 0pt; border-radius: 0; color: #000000; background-color: #ffffff; width: 640px;" width="640">
	<tbody>
		<tr>
			<td class="column column-1" style="mso-table-lspace: 0pt; mso-table-rspace: 0pt; font-weight: 400; text-align: left; padding-left: 25px; padding-right: 25px; vertical-align: top; padding-top: 25px; padding-bottom: 25px; border-top: 0px; border-right: 0px; border-bottom: 0px; border-left: 0px;" width="100%">
				{{ body }}
			</td>
		</tr>
	</tbody>
</table>

Help me please:- It was working before. No styles in GMail.

featuriz’s picture

Going back with : composer require 'drupal/symfony_mailer:^1.0@beta' is not working for me.

andyd328’s picture

Same issue here but reverting to "drupal/symfony_mailer": "1.1.0-beta1" has inline theming working for me.
My site uses the default commerce email receipt template.

jons’s picture

I found this too.
This is because there are 2 default templates now: email.html.twig and a new one email-wrap.html.twig .
email.html.twig just has {{body}} in it, all styling is in email-wrap.html.twig
I copied email-wrap.html.twig from the module to my theme template directory and transferred the styling over from my email.html.twig then copied the revised email.html.twig .

If you are using THEME_preprocess_email() that needs renaming to THEME_preprocess_email_wrap()

Clear caches

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.

fenstrat’s picture

This email wrapping caused inline styles to be stripped, issue for that is #3313675: Style tags in email body get stripped.