ActiveCampaign / mailmason

A complete toolset to streamline building and updating a set of consistent transactional emails.
https://postmarkapp.com/mailmason
MIT License
933 stars 66 forks source link

Create plain text only email template #45

Open irgipaulius opened 4 years ago

irgipaulius commented 4 years ago

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 commented 4 years ago

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"
  2. In /Gruntfile.js edit the deploy task:

    grunt.registerTask('deploy', ['shell:postmarkPush']) // remove 'default' task
  3. 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'))
    }
    });
  4. Run npm run push-postmark

  5. 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.