Send mail via mailgun
If you are using < v1.0 of this library there are breaking changes due to the changes in the mailgun api.
With npm do:
npm install mailgun-send
const mail = require('mailgun-send');
const domain = "myapp.com";
const key = "<mailgun api key>"
mail.config({
key: key,
domain: domain,
sender: `noreply@${domain}`
});
mail.send({
subject: 'hello from myapp!',
recipient: '[email protected]',
body: 'This is an email from myapp'
});
properties:
- key - Mailgun API key (required)
- sender - optional default sender
- recipient - optional default recipient
- subject - optional default subject
- body - optional default body
Defaults (except the API key) can be overriden on every send.
Send the msg.
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="https://myapp.com/resetpassword?key=' + key + '">here</a> to reset your password'
};
mail.send(msg);
});
MIT