docs/03-dev-howtos/17-working-with-emails.md
The email sign up forms include the Guardian Today footer, and the iframe embeds used by editorial in Composer. They are also used in the email sign up interactive atoms, examples here and here.
They live in routes like this: www.theguardian.com/email/form/<type>/<listID>
The form type can be article, footer, plain, plaintone, or plaindark:
The listID is the primary key of the email in ExactTarget. Editorial should know the listID. Any tone applied to the form will be determined by the listID (see later section).
When the form is submitted, the email address will be passed through Identity to ExactTarget, along with the ListID.
N.B. For email sign ups to work, the listID must be set up in ExactTarget by Editorial
The email preferences centre and the email newsletters page both pull data from EmailSubscriptions.scala
The email newsletters page does not use iframed forms
When adding a new EmailSubscription:
In the EmailSignupController.scala add an email name to ListIds, and assign it the value of the listID.
Within emailSignUp.scala.html map the email name to a tone in listIdTones
These interactives have their own repo and readme.
If you are adding a custom email sign up form somewhere, you will want to POST an email address and listID to https://www.theguardian.com/email.
An example implementation of this can be found in newsletters.scala.html.
@function validate(form) {
var emailAddress = $('.' + classes.textInput, form).val();
return typeof emailAddress === 'string' &&
emailAddress.indexOf('@') > -1;
}
type="email" on inputs:Fronts and articles can be rendered in email-friendly HTML by appending the URL parameter format=email. The response from these endpoints can be put into an email body and will render well in a wide variety of email clients.
For curating emails, you'll normally want to set up a custom front rather than co-opting an existing front. For this purpose, we have a notion of "Email fronts" (in addition to Commercial, Editorial, and Training). Content can be placed into email fronts in the same way as for web fronts, via the fronts tool.
As for web fronts, other properties of email fronts can be configured via the fronts config tool. This includes creating containers and choosing their layout types.
There are some differences between web fronts and email fronts.
format parameterThe use cases given (news-like vs feature-like) are just suggestions. In reality you can use whatever layout looks best for your design of email. For instance, longer emails will typically contain more containers with the fast layout since the email would take too long to scan from top to bottom otherwise.
Here's an example of each layout type along with a table summarising their differences:
LAYOUT | CARD | IMAGE? | STANDFIRST? | HEADLINE?
----------------|-----------------------------------
slow | 1st | big | yes | big
| others | none | yes | small
----------------|-----------------------------------
medium | 1st | big | yes | big
| others | none | no | small
----------------|-----------------------------------
fast | 1st | small | no | small
| others | none | no | small
Only a very limited subset of CSS will work in certain email clients. See here for a guide: https://www.campaignmonitor.com/css
Some key points:
<tr> for new rows rather than <div>, <p>, or anything else you might use if you've written HTML in the last decade<td> elements. Margins don't work properly in Outlook.<td> with percentage width<a> elements as this will break in Outlook (see https://github.com/guardian/frontend/pull/15634).