Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- var fs = require('fs');
- var path = require('path');
- var lodash = require('lodash');
- var request = require('request');
- var config = require(__basedir + '/config.json');
- class MailGunMailAdapter {
- constructor(domain, key, from) {
- this.domain = domain;
- this.key = key;
- this.from = from;
- }
- rawMail(opts, callback){
- request({
- method: 'post',
- url: 'https://api.mailgun.net/v3/'+this.domain+'/messages',
- auth: {
- user: 'api',
- pass: this.key,
- },
- form: lodash.assign({from: this.from}, opts),
- gzip: true,
- json: true,
- }, (err, res, data)=>{
- if (err) return callback(err);
- callback(null, data);
- })
- }
- }
- if (!config.mailer) {
- module.exports = {rawMail: function(opts, callback){callback(new Error("Mail not configured."))}};
- } else if (config.mailer.type == 'mailgun') {
- module.exports = new MailGunMailAdapter(config.mailer.options.domain, config.mailer.options.key, config.mailer.from);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement