📨 Create responsive emails with R
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
R
inst/rstudio
man
.Rbuildignore
.gitignore
.travis.yml
DESCRIPTION
LICENSE
NAMESPACE
README.md
mjml.Rproj

README.md

Travis-CI Build Status

mjml

Easily create responsive emails with MJML.

Install

Install the package.

devtools::install_github("JohnCoene/mjml")

Install MJML.

# Install with npm in a folder where you will use MJML
$> npm install mjml

# In the folder where you installed MJML you can now run:
$> ./node_modules/.bin/mjml -V

Pint to mjml from R.

mj_set("./node_modules/.bin/mjml")

Optionally install image chart to use ml_chart.

$> npm install mjml-chart --save

Templates

Inserts templates with RStudio addin.

  • Allura
  • Happy New Year
  • Card
  • Proof
  • Droids

Example

library(mjml)

mj_set("./node_modules/.bin/mjml") # path to MJML

# create email
mj_ml(
  mj_head(
    mj_preview("Preview text")
  ),
  mj_body(
    mj_container(
      mj_section(
        mj_column(
          width = "20%",
          mj_text("First column")
        ),
        mj_column(
          width = "80%",
          mj_text("Second column")
        )
      ),
      mj_section(
        mj_column(
          mj_image(paste0("https://media.vanityfair.com/photos/",
                          "54cbf3da998d4de83ba3602a/master/w_960,",
                          "c_limit/image.jpg")
          )
        )
      ),
      mj_section(
        mj_column(
          mj_chart(
            chd = "t:10,20,30|15,25,35"
          )
        )
      )
    )
  )
) %>% 
  mj_send(
    "me@gmail.com", 
    "him@gmail.com",
    "MJML Email",
    smtp = list(
      host.name = "smtp.gmail.com", 
      port = 465, 
      user.name = "me", 
      passwd = "pwd", 
      ssl = TRUE
    )
  )