218 points · by FriedPickles · 8y ago · 54 comments
For anyone who has similar concerns and wants to use something more customizable and reliable like Mailgun/Twilio, but wants access to the same elegant API showcased here, you can use something like this (admittedly naive) implementation:
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 {
twilioClient.messages.create({
body: msg,
to: to,
from: '+5555555555' // your number
});
}
}
This implementation wouldn't require that much extra effort to set up initially (i.e. signing up for two API credentials instead of one and installing two packages instead of one), but it gives you a lot more flexibility to configure the from address and phone number and might help you sleep easier at night.However, as a fellow startup founder, I think it's noble to support newer projects like this. As such, I've signed up for an account and plan to test it out for at least a month.
Send me a tweet @flutemail if you're interested, I'll let you know when it's ready (should be in about a month).
This was my thought as well. I've had a number of projects where I had to deliver large numbers of emails and SMS and the problem has never been the design of the API I used to send them. It's always about the delivery rates of those messages. Particularly with SMS we've had to be very careful with our providers, often needing to select a different one in different countries.
Funny part is, that Google has all the best ML engineers working for them, yet they seem to be unable to check a mail for spam... They can teach a computer to play Go at superhuman level yet they are not able to check an E-Mail for the words Viagra and Cialis.
More specifically, SPF exists for a domain owner (in this case, popcornnotify.com) to specify who is authorized to send mail on behalf of the host email.popcornnotify.com. This is set in a DNS record and used by spam filters to prevent spoofing and such.
There is an audience for every (useful) product!
EDIT: similarly, does it support MMS in addition to SMS?
Because of that simple reason, I'd only use this for optional stuff, but I struggle to think of a use case where notifications are optional.
ps. that said, this is a very attractive service to send SMS to Europe. I know of no service that undercuts $0.10 per SMS to European countries unless you buy in huge bulks.
Twilio looks to be under $0.10 for more than a few european countries I checked:
https://www.twilio.com/sms/pricing/ch https://www.twilio.com/sms/pricing/de https://www.twilio.com/sms/pricing/es https://www.twilio.com/sms/pricing/se https://www.twilio.com/sms/pricing/fi https://www.twilio.com/sms/pricing/nl
Looks like plivo has some good rates too:
https://www.plivo.com/pricing/ES/#!sms https://www.plivo.com/pricing/FR/#!sms https://www.plivo.com/pricing/FI/#!sms https://www.plivo.com/pricing/SE/#!sms
The monthly cost of a number with plivo seems a bit higher, overall, but also looks like they have free incoming SMS, which may end up being a much better deal for some use cases.
Well done.
Pricing: API keys cost $10 for each 1,000 messages and last one year.
It's right above the BUY API KEY button.It's just fairly small and not distinguished.