Closed Cre8tiveDigital closed 4 years ago
@Cre8tiveDigital I haven't personally looked into this but I imagine adding some task to this Mailgun file that finds all templates in a folder and loops through them.
grunt send --folder=transactional
or similar.
@Cre8tiveDigital - Here's an example how you'd do it.
Create the file /grunt/massmail.js
with the following code:
// Massmail
module.exports = function(grunt) {
grunt.registerTask('massmail', 'Send bunches of email, quickly ✌🏽.', () => {
const { dist } = grunt.config.get('paths');
// Allow matching pattern via --pattern="", default to all (*)
const pattern = grunt.option('pattern') || '*';
// Get and loop .html files matching the given pattern in /dist
const files = grunt.file.expand(`${dist}/${pattern}.html`);
files.forEach((filepath) => {
const filename = filepath.split('/').pop();
grunt.option('template', filename);
grunt.task.run('mailgun');
});
});
};
Then you can just run grunt massmail --pattern="somefolder/*"
The --pattern
option allows you to get as clever as you want and will match all .html
files with that pattern. WARNING the sample code will send all templates in the root /dist
folder by default.
@Cre8tiveDigital - Did you ever give this a go or come up with an alternate solution?
Hi, I was just wondering did you or anyone ever get the grunt mailgun task to send out more than one email test if there are multiple folders containing emails?
Thanks