mailmason icon indicating copy to clipboard operation
mailmason copied to clipboard

Create plain text only email template

Open irgipaulius opened this issue 6 years ago • 1 comments

I know I am not supposed to ask use-case questions here as described here, but I am having no success elsewhere, plus if there is no answer to my question, this could become a feature request.

Currently, in mailmason a template with no Layout set, fills both HTML and Text versions of the email template in postmarkapp.

How do I create a template in mailmason so the HTML field in postmark will be empty, and Text set?

That is important for creating small size ticket emails without bloating customer service management service.

irgipaulius avatar Jan 22 '20 09:01 irgipaulius

I don't really understand how grunt works, so my workaround:

  1. Added a script in package.json:
"push-postmark": "npm run build && node ./removeHTML.js && npm run deploy"
  1. In /Gruntfile.js edit the deploy task:
grunt.registerTask('deploy', ['shell:postmarkPush']) // remove 'default' task
  1. Create removeHTML.js file in root and insert:
const pathToTemplates = "./dist/postmark-templates"
const files = fs.readdirSync(pathToTemplates);
files.forEach(directory => {
    const templateDir = path.join(pathToTemplates, directory)
  const metaFile = JSON.parse(fs.readFileSync(path.join(templateDir, 'meta.json'), 'utf8'));
  if (!metaFile.LayoutTemplate){
    // if LayoutTemplate is not set, then delete the HTML content
    fs.unlinkSync(path.join(templateDir, 'content.html'))
  }
});
  1. Run npm run push-postmark

  2. Now if template hasn't got LayoutTemplate set, mailmason will push only the text version to postmarkapp.

It would be great to have this feature by default.

irgipaulius avatar Jan 23 '20 07:01 irgipaulius