Menu icon Foundation
Is there a command line version of inliner?

Hi

I just started with Foundation for Email. I'm trying to generate inky emails via php, and compile them into inlined html ready to send via phpmailer.

I found command line version of inky to call from php, is there similar one for inliner?

Thanks and regards

Brian

inkyinlinephpmailer

Hi

I just started with Foundation for Email. I'm trying to generate inky emails via php, and compile them into inlined html ready to send via phpmailer.

I found command line version of inky to call from php, is there similar one for inliner?

Thanks and regards

Brian

Derek McDermott about 3 years ago

This is the Gulp script that the foundation build process uses for inlining it would appear: -

// Inlines CSS into HTML, adds media query CSS into the <style> tag of the email, and compresses the HTML
function inliner(css) {
  var css = fs.readFileSync(css).toString();
  var mqCss = siphon(css);

  var pipe = lazypipe()
    .pipe($.inlineCss, {
      applyStyleTags: false,
      removeStyleTags: false,
      removeLinkTags: false
    })
    .pipe($.replace, '<!-- <style> -->', `<style>${mqCss}</style>`)
    .pipe($.htmlmin, {
      collapseWhitespace: true,
      minifyCSS: true
    });

  return pipe();
}

Looking at the node_modules in the project it would appear that it uses this inlining package:-

https://github.com/jonkemp/gulp-inline-css


I don't know PHP but presumably you can use that library?

Hope this helps.

Derek

Brian Tan about 3 years ago

Thanks for the reply. I'll check it out. I guess I could try to run  gulp from php too.

Derek McDermott about 3 years ago

Hi Brian,

You may not need to run gulp, as the "gulp-inline-css" library itself uses the "inline-css" library which appears to be a basic javascript library that runs outside of gulp.

See here:-

https://github.com/jonkemp/inline-css

So if from PHP you can run javascript then you should be able to get that library running from there - you may need something like browserify perhaps to give you access to the npm library (which requires Commonjs) from the browser.

If you can't get this to work from php and you're on the server side you could always run it in Nodejs perhaps?

Derek

Brian Tan about 3 years ago

Hi Derek,

I set up a simple gulpfile.js, generate inky htmls with stylesheet "foundation-emails.css" from inky dist folder.

var gulp = require('gulp'),
    inky = require('inky'),
    inlineCss = require('gulp-inline-css');

gulp.task('default', function() {
  return gulp.src('./*.html')
      .pipe(inky())
      .pipe(inlineCss())
      .pipe(gulp.dest('build/'));
});

Run gulp, then just send the htmls in build folder via phpMailer gmail_xoauth api.

Thanks for your help.