Created
February 12, 2018 19:55
-
-
Save panphora/214064c0cfba64a0480d17fc2c988896 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 <[email protected]>', // 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