timmyg / meteor-mandrill

Meteor package for sending email via Mandrill
18 stars 19 forks source link

No subject for API email? #4

Closed geekyme closed 10 years ago

geekyme commented 10 years ago

I think previously when I use this package I was able to customize my email subjects when i use the sendTemplate configuration. Right now that broke!

geekyme commented 10 years ago

Before 15 May, I was able to do this

Meteor.Mandrill.sendTemplate({
                key: 'xxxx',
                templateSlug: 'notifications',
                templateContent: [
                  {
                    name: 'username',
                    content: user.username
                  },
                ],
                toEmail: user.emails[0].address,
                subject: '['+title+'] '+me+' has continued after you!'
});

and the subject of my API email will be dynamically set. Now suddenly this does not work.

geekyme commented 10 years ago

I browse through your commits and I had no idea why the subject setting worked previously. But anyway, the behavior can be restored if you edit Meteor.Mandrill.sendTemplate method by including subject: options.subject

sendTemplate: function (options) {
        var url = "https://mandrillapp.com/api/1.0/messages/send-template.json",
            result;
        options = {
            data: {
                key: options.key,
                template_name: options.templateSlug,
                template_content: options.templateContent,
                message: {
                    from_email: options.fromEmail,
                    to: [
                        {
                            email: options.toEmail
                        }
                    ],
                    "global_merge_vars": options.globalMergeVars,
                    "merge_vars": options.mergeVars,
                    subject: options.subject
                },
                headers: [
                    {
                        "Content-Type": "application/json"
                    }
                ]
            }
        };
        try {
            result = HTTP.post(url, options);
        } catch (e) {
            console.log(e.stack);
        }
    }