Mailgen – Generates clean, responsive HTML emails for sending transactional mail

Generates clean, responsive HTML e-mails for sending transactional mail.

A Node.js package that generates clean, responsive HTML e-mails for sending transactional mail.

First, install the package using npm:

npm install mailgen --save

Then, start using the package by importing and configuring it:

var Mailgen = require('mailgen');

 

var mailGenerator = new Mailgen({

    theme: 'default',

    product: {

        name: 'Mailgen',

        link: 'https://mailgen.js/'

    }

});

Next, generate an e-mail using the following code:

var emailBody = mailGenerator.generate({

    body: {

        name: 'John Appleseed',

        intro: 'Welcome to Mailgen! We’re very excited to have you on board.',

        action: {

            instructions: 'To get started with Mailgen, please click here:',

            button: {

                color: 'green',

                text: 'Confirm Your Account',

                link: 'https://mailgen.js/confirm?s=d9729feb74992cc3482b350163a1a010'

            }

        },

        outro: 'Need help, or have questions? Just reply to this email, we'd love to help.'

    }

});

 

This code would output the following HTML template:

Reset Password E-mail

var emailBody = mailGenerator.generate({

    body: {

        name: 'John Appleseed',

        intro: 'You have received this email because a password reset request for your account was received.',

        action: {

            instructions: 'Click the button below to reset your password:',

            button: {

                color: 'red',

                text: 'Reset Your Password',

                link: 'https://mailgen.js/reset?s=b350163a1a010d9729feb74992c1a010'

            }

        },

        outro: 'If you did not request a password reset, no further action is required on your part.'

    }

});

Output

Reset Password Confirmation E-mail

var emailBody = mailGenerator.generate({

    body: {

        name: 'John Appleseed',

        intro: 'Your Mailgen account password has been reset successfully.',

        action: {

            instructions: 'Click the button below to sign in to your account:',

            button: {

                color: 'blue',

                text: 'Sign in to Mailgen',

                link: 'https://mailgen.js/login'

            }

        },

        outro: 'If you did not request a password reset, please reply to this e-mail and let us know immediately.'

    }

});

Output

Subscription Renewal E-mail

var emailBody = mailGenerator.generate({

    body: {

        name: 'John Appleseed',

        intro: 'Your subscription has been renewed successfully.',

        action: {

            instructions: 'You can review your purchase and check your account balance in your dashboard:',

            button: {

                color: 'blue',

                text: 'Go to Dashboard',

                link: 'https://mailgen.js/confirm?s=d9729feb74992cc3482b350163a1a010'

            }

        },

        outro: 'We hope you enjoy what we have to offer.'

    }

});

Output

The following open-source themes are bundled with this package:

We thank the contributing authors for creating these themes.

  1. After sending multiple e-mails to the same Gmail / Inbox address, they become grouped and truncated since they contain similar text, breaking the responsive template layout.

Simply sending the X-Entity-Ref-ID header with your e-mails will prevent grouping / truncation.

  • Want to add another theme?
  • Have an idea for a new e-mail type?

Open an issue and let’s talk about it!

Apache 2.0


Original URL: http://feedproxy.google.com/~r/feedsapi/BwPx/~3/XUiJeszfPeE/mailgen

Original article

Comments are closed.

Proudly powered by WordPress | Theme: Baskerville 2 by Anders Noren.

Up ↑

%d bloggers like this: