Skip to content


Subversion checkout URL

You can clone with
Download ZIP
Write your ActionMailer email templates in Markdown, send in html and plain text
Ruby HTML JavaScript CSS
Latest commit 066d039 @schneems v1.0.4
Failed to load latest commit information.
lib v1.0.4
test v1.0.4
.gitignore Add tests for markdown engine.
.travis.yml add travis config file Kramdown loads as default during runtime
Gemfile initial commit
Gemfile.lock v1.0.4
MIT-LICENSE initial commit Update
Rakefile v1.0.4
maildown.gemspec update gem deps


Markdown for your ActionMailer generated emails. Supports Rails 4.0+

Build Status


  • Fact: You should always send emails in text/html and text/plain at the same time
  • Fact: Writing email body content twice sucks
  • Fact: Markdown is amazing

So why not write your templates once in markdown, and have them translated to text and html? With Maildown now you can.



gem 'maildown'

Then run $ bundle install


In your app/views/<mailer> directory create a file with a .md.erb extension. When rails renders the email, it will generate html by parsing the markdown, and generate plain text by sending the email as is.


Once you've got a file named .md.erb in your mailer directory, I recommend verifing the format in your browser in development using a tool such as mail_view. You can toggle between html and text at the top to make sure both look like you expect.

Configure Markdown Renderer

Maildown uses kramdown by default. Kramdown is pure ruby, so it runs the same across all ruby implementations: jruby, rubinius, MRI, etc. You can configure another parser if you like using the Maildown::MarkdownEngine.set method and pasing it a block.

For example, if you wanted to use Redcarpet you could set it like this:

Maildown::MarkdownEngine.set do |text|
  carpet =, {})

When maildown needs an html document the block will be called with the markdown text. The result should be html.

Helpers in Markdown files

To get great looking emails in both html and plaintext generate your own links like this:

[Your Profile](<%= user_url(@user) %>)

Instead of

<%= link_to "Your Profile", user_url(@user) %>

Bonus: it's shorter!


This codebase depends on some metaprogramming to convince Action Mailer to render html and plain text from md. If you've got some ideas on how to add sane hooks into actionmailer to support this functionality more natively ping me @schneems

Alternative Implementations

There is another project that accomplishes the same thing by plataformatec: markerb.



Something went wrong with that request. Please try again.