Any way to hook into Meteor's account email functions?

What if I want to use my own third party transactional email API, instead of Meteor using an SMTP server? Is there some way to just access variables such as a user’s enrollment link, and pass it via API? e.g.

sendToMandrill = {
  templateId: 'some mandrill template ID',
  customContent: {
    verificationLink: Meteor.user().enrollmentLink
  }
};

I know this is not a direct answer to your question, but since you mention mandrill, their smtp api supports almost all sending features that their regular api offers. Check this out: https://mandrill.zendesk.com/hc/en-us/articles/205582117-How-to-Use-SMTP-Headers-to-Customize-Your-Messages

Also there is another workaround to use customized accounts email templates with mandrill over here: https://github.com/Wylio/meteor-mandrill/#using-meteors-accountsemailtemplates

Finally, there’s a package that achieves what you want over here: https://github.com/thesaucecode/meteor-forgot-password you might want to check out its source to see how they’ve done it.

I just used mandrill as an example since most people are familiar with it. I’ll actually be using Postmark, but they probably allow custom SMTP headers too. Thanks for the tip!

1 Like

We wanted to use Mandrill templates in place of Meteor accounts email because with Mandrill templates we can:

  • Choose to use an English or Chinese template depending on the customer profile
  • Can edit the HTML email at any time without redeploying the app.
  • We get handlebars templates in Mandrill
  • Mandrill provides some nice tools for editing and previewing your email templates.

There are probably better ways to do this, but we came up with this ‘hack’. In our app we can get the accounts verification link, but we can’t stop the mail from sending via Meteor’s account package. No matter, we shoot it down with a outbound reject rule. Meteor accounts uses our Mandrill SMTP, so we created a rule to match on a special subject which triggers Mandrill to reject the email.

Once that is out of the way, we pass the activation url to a Mandrill template instead.

in our code

In Mandrill

Bonus: Campaign Monitor provides a nice free email templating resource. Includes an online editor which allows you to download the final files with styles in-lined