All Projects â†’ premailer â†’ Premailer

premailer / Premailer

Licence: other
Preflight for HTML email

Programming Languages

ruby
36898 projects - #4 most used programming language
HTML
75241 projects
CSS
56736 projects

Projects that are alternatives of or similar to Premailer

Nodejs Mail Notifier
nodejs library to listen incoming mail
Stars: ✭ 136 (-93.74%)
Mutual labels:  mail
Iris.vim
đŸ“Ģ Simple mail client for Vim.
Stars: ✭ 148 (-93.19%)
Mutual labels:  mail
Docker Postfix
Simple SMTP server / postfix null relay host for your Docker and Kubernetes containers. Based on Alpine Linux.
Stars: ✭ 163 (-92.5%)
Mutual labels:  mail
React Native See More Inline
Show a "read more", "see more", "read less", "see less" inline with your text in React Native
Stars: ✭ 141 (-93.51%)
Mutual labels:  inline
Django Mail Templated
Send emails using Django template system
Stars: ✭ 146 (-93.28%)
Mutual labels:  mail
Org Msg
OrgMsg is a GNU/Emacs global minor mode mixing up Org mode and Message mode to compose and reply to emails in a Outlook HTML friendly style.
Stars: ✭ 153 (-92.96%)
Mutual labels:  mail
Mailspring
💌 A beautiful, fast and fully open source mail client for Mac, Windows and Linux.
Stars: ✭ 11,953 (+450.07%)
Mutual labels:  mail
Quotefixformac
QuoteFix for Apple Mail —
Stars: ✭ 181 (-91.67%)
Mutual labels:  mail
Laravel Disposable Email
Disposable email address validator for Laravel
Stars: ✭ 147 (-93.24%)
Mutual labels:  mail
Ip Biter
IP-Biter: The Hacker-friendly E-Mail (but not only) Tracking Framework
Stars: ✭ 166 (-92.36%)
Mutual labels:  mail
Laravel Mailable Test
An artisan command to easily test mailables
Stars: ✭ 143 (-93.42%)
Mutual labels:  mail
Django mail admin
The one and only django app to receive & send mail with templates and multiple configurations.
Stars: ✭ 140 (-93.56%)
Mutual labels:  mail
Imapbackup
A Python script for incremental backups of IMAP mailboxes
Stars: ✭ 156 (-92.82%)
Mutual labels:  mail
Mail Probe
邮įŽąæŽĸ针后台įŽĄį†įŗģįģŸ
Stars: ✭ 139 (-93.6%)
Mutual labels:  mail
Node Inline Cpp
Inline C++ with Node.js
Stars: ✭ 172 (-92.08%)
Mutual labels:  inline
Common Tags
🔖 Useful template literal tags for dealing with strings in ES2015+
Stars: ✭ 1,761 (-18.96%)
Mutual labels:  inline
Free Email Forwarding
The best free email forwarding for custom domains. Visit our website to get started (SMTP server)
Stars: ✭ 2,024 (-6.86%)
Mutual labels:  mail
Neomutt
✉ī¸ Teaching an Old Dog New Tricks -- IRC: #neomutt on irc.libera.chat
Stars: ✭ 2,343 (+7.82%)
Mutual labels:  mail
Postmark.js
Official Node.js library for the Postmark API
Stars: ✭ 177 (-91.85%)
Mutual labels:  mail
Modoboa Installer
An installer for Modoboa
Stars: ✭ 161 (-92.59%)
Mutual labels:  mail

Premailer README CI Gem Version

What is this?

For the best HTML e-mail delivery results, CSS should be inline. This is a huge pain and a simple newsletter becomes un-managable very quickly. This script is my solution.

  • CSS styles are converted to inline style attributes
    • Checks style and link[rel=stylesheet] tags and preserves existing inline attributes
  • Relative paths are converted to absolute paths
    • Checks links in href, src and CSS url('')
  • CSS properties are checked against e-mail client capabilities
    • Based on the Email Standards Project's guides
  • A plain text version is created (optional)

Installation

Install the Premailer gem from RubyGems.

gem install premailer

or add it to your Gemfile and run bundle.

Example

require 'premailer'

premailer = Premailer.new('http://example.com/myfile.html', :warn_level => Premailer::Warnings::SAFE)

# Write the plain-text output
# This must come before to_inline_css (https://github.com/premailer/premailer/issues/201)
File.open("output.txt", "w") do |fout|
  fout.puts premailer.to_plain_text
end

# Write the HTML output
File.open("output.html", "w") do |fout|
  fout.puts premailer.to_inline_css
end

# Output any CSS warnings
premailer.warnings.each do |w|
  puts "#{w[:message]} (#{w[:level]}) may not render properly in #{w[:clients]}"
end

Adapters

Premailer's default adapter is nokogiri if both nokogiri and nokogumbo are included in the Gemfile list. However, if you want to use a different adapter, you can choose to.

There are three adapters in total (as of premailer 1.10.0)

  1. nokogiri (default)
  2. nokogiri_fast
  3. nokogumbo

hpricot adapter removed due to its EOL, please use ~>1.9.0 version if You still need it..

NokogiriFast adapter improves the Algorithmic complexity of the running time by 20x with a slight compensation on memory. To switch to any of these adapters, add the following line. For example, if you want to include the NokogiriFast adapter,

Premailer::Adapter.use = :nokogiri_fast

Ruby Compatibility

See .github/workflows/actions.yml for which ruby versions are tested. JRuby support is close, contributors are welcome.

Premailer-specific CSS

Premailer looks for a few CSS attributes that make working with tables a bit easier.

CSS Attribute Availability
-premailer-width Available on table, th and td elements
-premailer-height Available on table, tr, th and td elements
-premailer-cellpadding Available on table elements
-premailer-cellspacing Available on table elements
-premailer-align Available on table elements
data-premailer="ignore" Available on link and style elements. Premailer will ignore these elements entirely.

Each of these CSS declarations will be copied to appropriate element's attribute.

For example

table { -premailer-cellspacing: 5; -premailer-width: 500; }

will result in

<table cellspacing='5' width='500'>

Configuration options

The behavior of Premailer can be configured by passing options in the initializer.

For example, the following will accept HTML from a string and will exclude unmergeable css from being added to the <head> of the output document.

premailer = Premailer.new(html_string, with_html_string: true, drop_unmergeable_css_rules: true)

See here for a full list of the available options.

Contributions

Contributions are most welcome. Premailer was rotting away in a private SVN repository for too long and could use some TLC. Fork and patch to your heart's content. Please don't increment the version numbers, though.

A few areas that are particularly in need of love:

  • Improved test coverage
  • Move un-repeated background images defined in CSS for Outlook

Credits and code

Thanks to all the wonderful contributors for their updates.

Thanks to Greenhood + Company for sponsoring some of the 1.5.6 updates, and to Campaign Monitor for supporting the web interface.

The source code can be found on GitHub.

Copyright by Alex Dunae (dunae.ca, e-mail 'code' at the same domain), 2007-2017. See LICENSE.md for license details.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].