Git Product home page Git Product logo

grunt-email-design's Introduction

Grunt Email Design Workflow

Designing and testing emails is a pain. HTML tables, inline CSS, various devices and clients to test, and varying support for the latest web standards.

This grunt task helps simplify things at the design stage.

  1. Compiles your SCSS to CSS

  2. Builds your email templates

  3. Inlines your CSS

  4. Uploads any images to a CDN (optional)

  5. Sends you a test email to your inbox

Requirements

  • Node.js - Install Node.js
  • Grunt-cli and Grunt (npm install grunt-cli -g)
  • Ruby - Install ruby with RVM
  • Premailer (gem install premailer hpricot nokogiri) - Inlines the CSS
  • Mailgun - Sends the email
  • Litmus (optional) - Tests the email across all clients/browsers/devices
  • Rackspace Cloud (optional) - Uses Cloud Files as a CDN

Getting started

If you haven't used Grunt before check out Chris Coyier's post on getting started with Grunt.

Clone this repo, cd to the directory, run npm install to install the necessary packages.

git clone https://github.com/leemunroe/grunt-email-design.git
cd grunt-email-design
npm install
grunt

How it works

CSS

This project uses SCSS. You don't need to touch the .css files, these are compiled automatically.

For changes to CSS, modify the .scss files.

Media queries and responsive styles are in a separate style sheet so that they don't get inlined. Note that only a few clients support media queries e.g. iOS Mail app.

Email templates and content

Handlebars is used for templating.

/layouts contains the standard header/footer HTML markup. You most likely will only need one layout template, but you can have as many as you like.

/emails is where your email content will go. To start you off I've included example transactional emails based on my simple HTML email template.

Generate your email templates

In terminal, run grunt. This will:

  • Compile your SCSS to CSS
  • Generate your email layout and content
  • Inline your CSS

See the output HTML in the dist folder. Open them and preview it the browser.

Alternatively run grunt watch. This will check for any changes you make to your .scss and .hbs templates, then automatically run the tasks. Saves you having to run grunt every time.

Send the email to yourself

  • Sign up for a Mailgun account (it's free)
  • Open up Gruntfile.js
  • Replace 'MAILGUN_KEY' with your actual Mailgun API key
  • Change the sender and recipient to your own email address (or whoever you want to send it to)

Run grunt send --template=transaction.html. This will email out the template you specify.

Change 'transaction.html' to the name of the email template you want to send.

How to test with Litmus

If you have a Litmus account and want to test the email in multiple clients/devices, create a new test in Litmus, copy the email address they tell you to send the email to, open up Gruntfile.js and paste it where the recipient goes. Then run grunt send --template=TEMPLATE_NAME.html to send the email to Litmus.

<img src="http://f.cl.ly/items/1T003x0t1m2k0a2O302c/Image%202014-06-10%20at%2010.11.01%20AM.png" width=-"500">

CDN and working with image assets

If your email contains images you'll want to serve them from a CDN. This Gruntfile has support for Rackspace Cloud Files (pricing).

  • Sign up for a Rackspace Cloud account (use the Developer Discount for $300 credit)
  • Create a new Cloud Files container
  • Open up Gruntfile.js
  • Change 'cloudfiles' settings to your settings (you can find your Rackspace API key under your account settings)
  • Make any other config changes as per grunt-cloudfiles instructions

Run grunt cdnify to run the default tasks as well as upload any images to your CDN.

Run grunt cdnify send --template=branded.html to send the email to yourself with the 'CDNified' images.

Sample email templates

I've added a few templates to help you get started.

grunt-email-design's People

Contributors

aleksa-savic avatar dmyers avatar jjasghar avatar joeyespo avatar jongotlin avatar leemunroe avatar madshensel avatar majksner avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.