Skip to content

Redirect multiple emails to a single developer's/QA's account. Useful during development and testing.

Notifications You must be signed in to change notification settings

beaucoo/mandrill-redirect

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

mandrill-redirect

Redirect emails declared in Mandrill template data to a single developer's/QA's email. Useful during development and testing.

E.g. Given two recipients [email protected], [email protected] and a redirect email of [email protected] the resulting recipients will be [email protected] and [email protected].

##Use

Install via npm install mandrill-redirect

and use:


    var redirect = require('mandrill-redirect');
    redirect(template, "[email protected]"); // Returns true/false

rewrites a Mandrill template:


    {
        message:{
            to: ["[email protected]", "[email protected]"],
            merge_vars: [
                {
                    rcpt: "[email protected]",
                    vars: [...]
                },
                {
                    rcpt: "[email protected]",
                    vars: [...]
                }
            ],
            recipient_metadata:[
                {
                    "rcpt": "[email protected]",
                    "values": [...]
                },
                {
                    "rcpt": "[email protected]",
                    "values": [...]
                }
            ]
        }
    }

to:


    {
        message: {
            to: ["[email protected]", "[email protected]"],
            merge_vars: [
                {
                    rcpt: "[email protected]",
                    vars: [...]
                },
                {
                    rcpt: "[email protected]",
                    vars: [...]
                }
            ],
            recipient_metadata:[
                {
                    "rcpt": "[email protected]",
                    "values": [...]
                },
                {
                    "rcpt": "[email protected]",
                    "values": [...]
                }
            ]
        }
    }

Also:

  • to is mandatory and must have length
  • merge_vars is optional but if provided must match the length of to
  • recipient_metadata is optional but if provided must match the length of to
  • If no email is given for redirecting then any template manipulation is skipped.
  • The return value is true/false indicating success/failure. The template is rewritten in place.

About

Redirect multiple emails to a single developer's/QA's account. Useful during development and testing.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published