Skip to content

Instantly share code, notes, and snippets.

@solace
Last active November 20, 2020 06:58
Show Gist options
  • Save solace/cb927e62ea8502d21895cd53e75edded to your computer and use it in GitHub Desktop.
Save solace/cb927e62ea8502d21895cd53e75edded to your computer and use it in GitHub Desktop.
Meteor: Extend default Email.send invocation

Use a non-SMTP mail method in Meteor

Requirements:

  • lodash (or underscore, you may need to change your _ functions to suit)
  • Meteor email package
Meteor.startup(function () {
  var sendEmail = _.bind(Email.send, Email);
  _.extend(Email, {
    send: function (options) {
      if (/* your custom mail method exists */) {
        /* your custom mail method, pull the options you need from `options` */
        console.log('CUSTOM MAIL METHOD');
      } else {
        /* use the SMTP method */
        console.log('DEFAULT MAIL METHOD');
        sendEmail(options);
      }
    }
  });
});
@Natas0007
Copy link

Awesomeness! Others apparently don't think this is possible! Well done!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment