MJML Signoff
Included in Premail
Why a custom component?
A common best practice in emails is to include a photo along side your "signoff" (such as "Best, Tamara").
Getting images to "float" alongside text, including in mobile contexts, can be
tricky. <mj-signoff>
simplifies this.
Example use
An example of this can be found in the example email's
content/signoff.hbs
template:
- MJML
- HTML
- Rendered component
<mj-signoff
closing="Thank you,"
name="John Q. Public"
title="Your Friendly Neighbor"
image-src="https://picsum.photos/75/100"
image-width="75px"
image-height="100px"
image-padding="0 0 12px 0"
image-alt=""
>
<p><a href="https://example.com">Example, Inc.</a></p>
</mj-signoff>
Unminified HTML:
<!--[if mso | IE]><table align="center" border="0" cellpadding="0" cellspacing="0" class="component-signoff-outlook" role="presentation" style="width:600px;" width="600" bgcolor="#ffffff" ><tr><td style="line-height:0px;font-size:0px;mso-line-height-rule:exactly;"><![endif]-->
<div class="component-signoff" style="background:#ffffff;background-color:#ffffff;margin:0px auto;max-width:600px;">
<table align="center" border="0" cellpadding="0" cellspacing="0" role="presentation" style="background:#ffffff;background-color:#ffffff;width:100%;">
<tbody>
<tr>
<td style="direction:ltr;font-size:0px;padding:0;padding-bottom:18px;padding-left:18px;padding-right:18px;padding-top:0px;text-align:center;">
<!--[if mso | IE]><table role="presentation" border="0" cellpadding="0" cellspacing="0"><tr><td class="" width="600px" ><table align="center" border="0" cellpadding="0" cellspacing="0" class="signoff-outlook" role="presentation" style="width:564px;" width="564" ><tr><td style="line-height:0px;font-size:0px;mso-line-height-rule:exactly;"><![endif]-->
<div class="signoff" style="margin:0px auto;max-width:564px;">
<table align="center" border="0" cellpadding="0" cellspacing="0" role="presentation" style="width:100%;">
<tbody>
<tr>
<td style="direction:ltr;font-size:0px;padding:10px 0;text-align:left;">
<!--[if mso | IE]><table role="presentation" border="0" cellpadding="0" cellspacing="0"><tr><td class="column-outlook signoff__image-wrapper-outlook" style="vertical-align:top;width:75px;" ><![endif]-->
<div class="mj-column-px-75 mj-outlook-group-fix column signoff__image-wrapper" style="font-size:0px;text-align:left;direction:ltr;display:inline-block;vertical-align:top;width:100%;">
<table border="0" cellpadding="0" cellspacing="0" role="presentation" width="100%">
<tbody>
<tr>
<td style="vertical-align:top;padding:0;">
<table border="0" cellpadding="0" cellspacing="0" role="presentation" style width="100%">
<tbody>
<tr>
<td align="center" vertical-align="top" class="signoff__image" style="font-size:0px;padding:0 0 12px 0;word-break:break-word;">
<table border="0" cellpadding="0" cellspacing="0" role="presentation" style="border-collapse:collapse;border-spacing:0px;">
<tbody>
<tr>
<td style="width:75px;">
<img alt=""height="100" src="https://picsum.photos/75/100" style="border:0;display:block;outline:none;text-decoration:none;height:100px;width:100%;font-size:18px;" width="75" >
</td>
</tr>
</tbody>
</table>
</td>
</tr>
</tbody>
</table>
</td>
</tr>
</tbody>
</table>
</div>
<!--[if mso | IE]></td><td class="column-outlook signoff__text-wrapper-outlook" style="vertical-align:top;width:282px;" ><![endif]-->
<div class="mj-column-per-50 mj-outlook-group-fix column signoff__text-wrapper" style="font-size:0px;text-align:left;direction:ltr;display:inline-block;vertical-align:top;width:100%;">
<table border="0" cellpadding="0" cellspacing="0" role="presentation" width="100%">
<tbody>
<tr>
<td style="vertical-align:top;padding:0;">
<table border="0" cellpadding="0" cellspacing="0" role="presentation" style width="100%">
<tbody>
<tr>
<td align="left" vertical-align="top" class="signoff__text" style="font-size:0px;padding:0 10px;word-break:break-word;">
<div style="font-family:
'Source Sans Pro',
Source Sans Pro, -apple-system, BlinkMacSystemFont, Segoe UI, Liberation Sans, Helvetica, Arial, sans-serif, Apple Color Emoji, Segoe UI Emoji, Segoe UI Symbol
;font-size:18px;line-height:1;text-align:left;color:#555555;">
<p class="signoff__closing" style="margin-top: 0; margin-left: 0; margin-right: 0; margin-bottom: 18px; font-size: 18px; mso-line-height-rule: exactly; line-height: 1;">Thank you,
</p>
<p class="signoff__name" style="margin-top: 0; margin-left: 0; margin-right: 0; font-size: 18px; margin-bottom: 0px; mso-line-height-rule: exactly; line-height: 1;">John Q. Public
</p>
<p class="signoff__title" style="margin-top: 0; margin-left: 0; margin-right: 0; font-size: 18px; margin-bottom: 0px; mso-line-height-rule: exactly; line-height: 1;">Your Friendly Neighbor
</p>
<div class="signoff__custom">
<p style="margin-top: 0; margin-left: 0; margin-right: 0; margin-bottom: 18px; font-size: 18px; mso-line-height-rule: exactly; line-height: 1;">
<a href="https://example.com" style="font-weight: bold; text-decoration: underline; color: purple;">Example, Inc.
</a>
</p>
</div>
</div>
</td>
</tr>
</tbody>
</table>
</td>
</tr>
</tbody>
</table>
</div>
<!--[if mso | IE]></td></tr></table><![endif]-->
</td>
</tr>
</tbody>
</table>
</div>
<!--[if mso | IE]></td></tr></table></td></tr></table><![endif]-->
</td>
</tr>
</tbody>
</table>
</div>
<!--[if mso | IE]></td></tr></table><![endif]-->
Strings cannot contain HTML elements, however any content within the element itself is placed in the text column below the optional strings, as demonstrated above. Styling options are also provided in Premail's theme settings.
<mj-signoff> options
option | unit | details | default value |
---|---|---|---|
closing | string | Optional closing, e.g. Thank you, | none |
name | string | Optional name, e.g. John Q. Public | none |
title | string | Optional title, e.g. Wild and Crazy Guy | none |
title2 | string | Optional title line two, e.g. ACME Corp. | none |
title3 | string | Optional title line three, e.g. (202) 555-1212 | none |
section-padding | pixels | Applies to entire element | 10px 0 |
section-align | left , center , right | Alignment of element as a whole | left |
background-color | color | Applies to entire element | none |
image-position | left , right | Where the image should appear relative to the text | left |
image-padding | pixels | Applies only to the image column | none |
image-src | URL | Location of image | none |
image-width | pixels | Width of image | none |
image-height | pixels | Height of image | none |
image-alt | string | Alternative text for image (you may legitimately wish to leave this blank; see the spec for graphical representation, decorative images and example 2 here) | none |
text-column-padding | pixels | Applies only to the text column | 0 10px |
Alternatives
Instead of using this component, you can use the
<mj-group>
element, but note its
warning for iOS 9.
If you are not using an image in your sign-off, or intend for the image to be on
a line without text wrapping around it (such as an image of a signature), you
can simply use MJML's <mj-text>
element.