cubiclesoft / email_sms_mms_gateways Goto Github PK
View Code? Open in Web Editor NEWA simple repo containing a list of known e-mail to SMS, MMS, and Rich Messaging carrier gateways in JSON format under a MIT or LGPL license.
A simple repo containing a list of known e-mail to SMS, MMS, and Rich Messaging carrier gateways in JSON format under a MIT or LGPL license.
Apparently Japan doesn't do e-mail to SMS, just e-mail. So, strictly speaking, the entries in this repo, while apparently valid, are just plain ol' e-mail address domains that get prefixed with the mobile phone number. Does it matter though since they are actually mobile carriers that they don't actually send a SMS to the recipient? IMO, the Wikipedia user who removed the entries is being overly pedantic with this change. Open to suggestions.
This was a little more effort than I anticipated, but here is the code in case anyone is interested. There may be a cleaner way to accomplish this without explicitly looping through each list, if so I'd be curious to see how.
I used Json.Net, credit to this site http://csharphelper.com/blog/2013/05/how-to-extract-only-some-of-the-information-from-a-json-file-in-c/ for some of the approach.
using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
public Dictionary<string, CountryInfo> GetCarriers()
{
// Get the data file.
string jsonPath = @"your path here";
string serialization = "";
Dictionary<string, CountryInfo> Country = new Dictionary<string, CountryInfo>();
Dictionary<string, Dictionary<string, CarrierInfo>> SMS_Carriers = new Dictionary<string,Dictionary<string,CarrierInfo>>();
Dictionary<string, Dictionary<string, CarrierInfo>> MMS_Carriers = new Dictionary<string, Dictionary<string, CarrierInfo>>();
StreamReader sr = File.OpenText(jsonPath);
serialization = sr.ReadToEnd();
Dictionary<string, object> dict = JsonConvert.DeserializeObject<Dictionary<string, object>>(serialization);
// Get the countries.
Dictionary<string, string> countries = JsonConvert.DeserializeObject<Dictionary<string, string>>(dict["countries"].ToString());
foreach (KeyValuePair<string, string> pair in countries)
{
CountryInfo country_info = new CountryInfo(pair.Key, (string)pair.Value, new List<CarrierInfo>(), new List<CarrierInfo>());
Country.Add(country_info.CountryAbbreviation, country_info);
}
// Get the SMS carriers.
Dictionary<string, Dictionary<string, string[]>> jsonCarriers = JsonConvert.DeserializeObject<Dictionary<string, Dictionary<string, string[]>>>(dict["sms_carriers"].ToString());
foreach (string countryAbbr in jsonCarriers.Keys)
{
Dictionary<string, CarrierInfo> smscarriers = new Dictionary<string, CarrierInfo>();
foreach (string carrierAbbr in jsonCarriers[countryAbbr].Keys)
{
CarrierInfo carrier = new CarrierInfo(jsonCarriers[countryAbbr][carrierAbbr][0], carrierAbbr, jsonCarriers[countryAbbr][carrierAbbr].Skip(1).ToList());
smscarriers.Add(carrier.CarrierAbbreviation, carrier);
}
SMS_Carriers.Add(countryAbbr, smscarriers);
}
// Get the MMMS carriers
jsonCarriers = JsonConvert.DeserializeObject<Dictionary<string, Dictionary<string, string[]>>>(dict["mms_carriers"].ToString());
foreach (string countryAbbr in jsonCarriers.Keys)
{
Dictionary<string, CarrierInfo> MMScarriers = new Dictionary<string, CarrierInfo>();
foreach (string carrierAbbr in jsonCarriers[countryAbbr].Keys)
{
CarrierInfo carrier = new CarrierInfo(jsonCarriers[countryAbbr][carrierAbbr][0], carrierAbbr, jsonCarriers[countryAbbr][carrierAbbr].Skip(1).ToList());
MMScarriers.Add(carrier.CarrierAbbreviation, carrier);
}
MMS_Carriers.Add(countryAbbr, MMScarriers);
}
// Populate return object
foreach (string countryAbbr in Country.Keys)
{
Country[countryAbbr].SMSCarriers.AddRange(SMS_Carriers[countryAbbr].Values.ToList());
if (MMS_Carriers.ContainsKey(countryAbbr))
Country[countryAbbr].MMSCarriers.AddRange(MMS_Carriers[countryAbbr].Values.ToList());
}
return Country;
}
public class CarrierInfo
{
public string CarrierAbbreviation { get; set; }
public string CarrierName { get; set; }
public List<string> Emails { get; set; }
public CarrierInfo(string carrierName, string carrierAbbreviation, List<string> emails)
{
CarrierName = carrierName;
CarrierAbbreviation = carrierAbbreviation;
Emails = emails;
}
public override string ToString()
{
return CarrierName;
}
}
public class CountryInfo
{
public string CountryAbbreviation {get; set;}
public string CountryName { get; set; }
public List<CarrierInfo> SMSCarriers { get; set; }
public List<CarrierInfo> MMSCarriers { get; set; }
public CountryInfo(string countryAbbreviation, string countryName, List<CarrierInfo> smsCarriers, List<CarrierInfo> mmsCarriers)
{
CountryAbbreviation = countryAbbreviation;
CountryName = countryName;
SMSCarriers = smsCarriers;
MMSCarriers = mmsCarriers;
}
public override string ToString()
{
return CountryName;
}
}
I'm not sure if the gateway for google voice has ever "officially" worked, but it appears to immediately fail with a message of "Delivery to the following recipient failed permanently:".
May be best to remove it from the list.
Per Roger Wireless - SMS should be @pcs.rogers.com
Your email address will be your 10-digit Rogers wireless phone number followed by @pcs.rogers.com. Example: [area code and phone number]@pcs.rogers.com
Per Ting Support - Email to text is not supported
IMPORTANT: Our network partners do not provide service level guarantees for email-to-SMS messaging delivery. As a result, the email-to-text functionality is unsupported on the Ting network. This service may not work correctly, or at all, with certain devices and/or conditions
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.