Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create plain text only email template #45

Open
irgipaulius opened this issue Jan 22, 2020 · 1 comment
Open

Create plain text only email template #45

irgipaulius opened this issue Jan 22, 2020 · 1 comment

Comments

@irgipaulius
Copy link

irgipaulius commented Jan 22, 2020

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
Copy link
Author

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant