dsachitano / node-mailgun-send

Send mail via mailgun

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

mailgun-send Code Climate Dependency Status

Send mail via mailgun

install

With npm do:

npm install mailgun-send

usage

var mail = require('mailgun-send');

mail.config({
  key: '<mailgun api key>',
  sender: 'noreply@myapp.com'
});

mail.send({
  subject: 'hello from myapp!',
  recipient: 'user@email.com',
  body: 'This is an email from myapp'
});

mail.config()

properties:

  • key - Mailgun API key (required)
  • sender - optional default sender
  • recipient - optional default recipient
  • subject - optional default subject
  • body - optional default body
  • batchRecipients - Send 1 email to all recipients instead of individual to each recipient (default true)

Defaults (except the API key) can be overriden on every send.

mail.send()

Send the msg.

practical example

Implement a password reset scheme...

// Password reset feature
app.post('/forgotPassword', function (req,res) {
  key = getTempPasswordResetKey();

  var msg = {
    subject: 'Password reset confirmation',
    recipient: req.body.email
    body: 'Click <a href="http://myapp.com/resetpassword?key=' + key + '">here</a> to reset your password'
  };

  mail.send(msg);

});

license

MIT

About

Send mail via mailgun

License:MIT License


Languages

Language:JavaScript 100.0%