Since programatically sending a text with Meteor from the user's own cell phone number seems to be problematic (see this), I'm thinking the way to do this could be to send the SMS / texts as an email.
I often do this manually from work when I text my wife from an email client; the "rub" is that the format for the addresses to use differ based on carrier. e.g., when I SMS my wife via email, I use and address like the following:
0871632810@txt.att.net
That obviously works for someone using att.net as their carrier. For other carriers, other naming schemes are used (which can be found here and here.
So my idea is, if I know the user's phone number and their email address, I can cobble together the correct SMS address to use as the "from" in an email. e.g., given the following:
Phone == 0871632810
Email == guinevere@att.net
...I could have a function like (pseudocode):
string getSMSAsEmailAddr(phone, email) {
var emailAsSMS;
if (email.contains('att.net') {
emailAsSMS = 'txt.att.net';
}
else if (email.contains('comcast.net') {
emailAsSMS = 'comcastpcs.textmsg';
}
. . .
return phone + '@' + emailAsSMS;
}
The problem is, can a person's carrier/valid SMS address always be determined by their email address? I'm thinking no - for example, what if a person has comcast but their email address is gmail, or something else altogether?
Is it necessary, in order to reliably build the needed SMS address, to know the user's carrier (both sender and receiver) and leave the email address out of the equation?
There is at least one for-pay service for returning carriers for a phone number, such as this API. There is also one called "CallFire" but both of these cost moolah ($$). I prefer a free option (yes, I'm a cheapskate).
I'm thinking the way to do this is something like:
var phoneNum = $('#phoneNumber').val(); // returns something like '0871632810'
var carrier = getCarrierForPhoneNumber(phoneNum);// returns something like 'att' or 'comcast' or whatever
var textAddrSuffix = getTextAddrSuffixForCarrierName(carrier); // returns (if carrier is 'att', as an example) something like '@txt.att.net'
var textAddrViaEmail = phoneNum + textAddrSuffix; // returns something like '0871632810@txt.att.net'
textAddrViaEmail can now be used as either the "to" or "from" email address.
No, but there is a library with a rather large database of them over at https://github.com/typpo/textbelt.