Skip to content

Instantly share code, notes, and snippets.

@panphora
Created February 12, 2018 19:55
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save panphora/214064c0cfba64a0480d17fc2c988896 to your computer and use it in GitHub Desktop.
Save panphora/214064c0cfba64a0480d17fc2c988896 to your computer and use it in GitHub Desktop.
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