This library offers a cost-effective alternative to texting services APIs such as TextMagic and Twilio. By using SMS-to-Email and Email-to-SMS services often offerd by carriers, a user can text an email address, and have this read and managed by a Python script, and the Python script can respond. Currently, there are 8 supported carriers, though I plan to add more as requests come in. These carriers are:
- Verizon
- Alltel
- AT&T
- Boost Mobile
- Sprint
- T Mobile
- US Cellular
- Virgin Mobile
SMSlib is very easy to use. At the moment, only email addresses hosted by AOL will work, though I plan to add support
for others later. To start, we need to create a messenger
like in the next example:
import smslib
client = smslib.messenger('youremail@aol.com', 'yourpassword')
Lets begin by sending a message to (555) 123-4567:
client.send("5551234567", "yourcarrier", "Hello World!")
Receiving a text is very similar:
client.recvfrom("5551234567", "yourcarrier")
This will return the oldest message sent by the number, or None
if no messages are found.