Create an Email Template
To create Iterable templates, see Iterable's documentation on templates). Skip to general email development tips.
The following instructions are for templates being sent through Mailgun.
We use Ruby on Rail's ActionMailer as our foundation for emailing through Mailgun at Handshake. We use HAML for templating emails nowadays, though some older emails in our codebase use Foundation or Inky.
At this point, you'll have a few questions to answer:
- Will the new email be sent through an existing mailer, or a new mailer?
- Mailers live within
app/mailerswithin the owning team's packs. - To create a new mailer, use the script:
bundle exec rails g notifications:template:mailer <name>
- Mailers live within
- From which email domain do I want my email to be sent?
- Will my email use an existing layout, or a new layout?
- Existing shareable layouts include: rebrand_student_email and rebrand_employer_email.
Here are some example PRs:
Note the various components:
- stylesheet
- HAML template
- reusable footer and header templates
- Mailer
- layout
- mailgun_variables
- delivery_method_options: Email::Config.delivery_method_options(:notification_domain),
- this sets which email domain we send from!
- i18n
Testing
To test your email template, follow the instructions in Test an Email.
General email development tips
Email development is slower to evolve than general web development. https://www.caniemail.com/ is a useful tool to get the latest information on which CSS and HTML properties are supported across various email clients. For example, as of now, — flex CSS, grid CSS, and .svg files are not supported, and do not render as expected within email clients.
Mobile — Routes that are listed in https://joinhandshake-staging.com/apple-app-site-association open our mobile app, if opened on a mobile device with a logged-in Handshake app.
Outlook — Outlook email clients tend to render in unexpected ways; see Jira history for examples. For one, image widths/heights need to be set in the element properties, since that is the only way that Outlook respects image size constraints.
Here are some Outlook email template resources:
- https://stackoverflow.design/email/base/mso/
- https://www.litmus.com/blog/a-guide-to-rendering-differences-in-microsoft-outlook-clients
- https://templates.mailchimp.com/development/css/outlook-conditional-css/
- https://www.caniemail.com/
- https://haml.info/docs/yardoc/file.REFERENCE.html#html-comments-
- Example PRs: