Skip to content

Instantly share code, notes, and snippets.

@panphora

panphora/notify.js

Created Feb 12, 2018
Embed
What would you like to do?
const mailgun = require('mailgun-js')({apiKey: api_key, domain: domain});
const twilio = new require('twilio')(accountSid, authToken);
export default function notify (to, msg, options) {
if (Array.isArray(to)) {
to.forEach((toSingle) => notify(toSingle, msg, options));
return;
}
if (to.includes("@")) {
mailgun.messages().send({
from: 'Your name <yourname@example.com>', // your email
to: to,
subject: options && options.subject,
text: msg
});
} else {
twilio.messages.create({
body: msg,
to: to,
from: '+5555555555' // your number
});
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.