All Projects → clayshieh → PySMS

clayshieh / PySMS

Licence: GPL-3.0 license
Simple Python API that that allows you to send texts via SMTP with a best effort approach and process replies via IMAP

Programming Languages

python
139335 projects - #7 most used programming language

Projects that are alternatives of or similar to PySMS

Gotwilio
Twilio library for Go (golang).
Stars: ✭ 328 (+1626.32%)
Mutual labels:  twilio, sms
SmsForwarder
短信转发器——监控Android手机短信、来电、APP通知,并根据指定规则转发到其他手机:钉钉群自定义机器人、钉钉企业内机器人、企业微信群机器人、飞书机器人、企业微信应用消息、邮箱、bark、webhook、Telegram机器人、Server酱、PushPlus、手机短信等。包括主动控制服务端与客户端,让你轻松远程发短信、查短信、查通话、查话簿、查电量等。(V3.0 新增)PS.这个APK主要是学习与自用,如有BUG请提ISSUE,同时欢迎大家提PR指正
Stars: ✭ 8,386 (+44036.84%)
Mutual labels:  sms, smtp
React Native Phone Verification
The best React Native example for phone verification (an alternative to Twitter Digits).
Stars: ✭ 332 (+1647.37%)
Mutual labels:  twilio, sms
plivo
This package enables to send message or OTP to any mobile.This package uses external plivo api.
Stars: ✭ 20 (+5.26%)
Mutual labels:  twilio, sms
30 Days Of Python 3.6
This is a soon-to-be archived project version of 30 Days of Python. The original tutorial still works but we have an updated version in the works right now.
Stars: ✭ 98 (+415.79%)
Mutual labels:  twilio, sms
dj-twilio-sms
Twilio SMS Integration for Django
Stars: ✭ 15 (-21.05%)
Mutual labels:  twilio, sms
Twilio Java
A Java library for communicating with the Twilio REST API and generating TwiML.
Stars: ✭ 371 (+1852.63%)
Mutual labels:  twilio, sms
module-twilio
Magento 2 Customer SMS notifications with Twilio
Stars: ✭ 29 (+52.63%)
Mutual labels:  twilio, sms
Faxserver
Send and Receive Faxes Using The Twilio Programmable Fax API.
Stars: ✭ 92 (+384.21%)
Mutual labels:  twilio, sms
Authy
Rinvex Authy is a simple wrapper for @Authy TOTP API, the best rated Two-Factor Authentication service for consumers, simplest 2fa Rest API for developers and a strong authentication platform for the enterprise.
Stars: ✭ 34 (+78.95%)
Mutual labels:  twilio, sms
sample-template-nodejs
A template repository serving as the base for new Twilio sample apps
Stars: ✭ 16 (-15.79%)
Mutual labels:  twilio, sms
Simple Sms
Send and receive SMS messages with Laravel
Stars: ✭ 181 (+852.63%)
Mutual labels:  twilio, sms
actions-sms
Send an SMS through GitHub Actions
Stars: ✭ 108 (+468.42%)
Mutual labels:  twilio, sms
laravel-authy
Rinvex Authy is a simple wrapper for @authy TOTP API, the best rated Two-Factor Authentication service for consumers, simplest 2fa Rest API for developers and a strong authentication platform for the enterprise.
Stars: ✭ 35 (+84.21%)
Mutual labels:  twilio, sms
Node-js-functionalities
This repository contains very useful restful API's and functionalities in node-js containing many important tutorial code for mastering node-js, all tutorials have been published on medium.com, tutorials link is given below
Stars: ✭ 69 (+263.16%)
Mutual labels:  twilio, smtp
Spoke
mass-contact text/SMS distribution tool
Stars: ✭ 367 (+1831.58%)
Mutual labels:  twilio, sms
twilito
A tiny, zero dependency Ruby helper for sending text messages with Twilio 💬
Stars: ✭ 16 (-15.79%)
Mutual labels:  twilio, sms
org-mode-sms-inbox
Harvest org-mode todos with Dropbox, Twilio, and IFTTT.
Stars: ✭ 19 (+0%)
Mutual labels:  twilio, sms
Twilio Csharp
Twilio C#/.NET Helper Library for .NET Framework 3.5+ and supported .NET Core versions
Stars: ✭ 541 (+2747.37%)
Mutual labels:  twilio, sms
Botkit
Botkit is an open source developer tool for building chat bots, apps and custom integrations for major messaging platforms.
Stars: ✭ 10,555 (+55452.63%)
Mutual labels:  twilio, sms

PySMS

Simple Python API that that allows you to send texts via SMTP with a best effort approach and process replies via IMAP

Motivation

I could afford shared hosting that gave me unlimited email accounts but I couldn't (didn't want to pay for) a SMS API such as Twilio so I decided to write my own given that this email to texting functionality exists already.

Prerequisites

The only Python Libraries needed are included in the standard Python libraries but incase you don't have them you can install them with the following command.

pip install smtplib imaplib email datetime time random inspect logging

Getting Started

Import PySMS into your Python file by including the following line

import PySMS

Usage

Not sure what IMAP and SMTP servers are? Read here

For only texting capability, initialize the client with your address, password, smtp_server, smtp_port and an optional ssl flag.

ps = PySMS.PySMS(address="[email protected]", password="password", smtp_server="smtp.example.com", smtp_port="465", ssl=True)

To enable the texting callback capability, you also have to initialize the client with your imap_server. ps = PySMS.PySMS(address="[email protected]", password="password", smtp_server="smtp.example.com", smtp_port="465", imap_server="imap.example.com", ssl=True)

Add numbers with corresponding carriers that you want the client to text whenever you call the text() method using the add_number() method.

ps.add_number("5551231234", "att")

Whenever you want to send a text with no callback functionality to all added numbers call the text() method

ps.text("This is a text!")

If you want to text just one number, set the optional number argument in the text() method

ps.text("This is an individual text", number="5551231234")

You can also add a callback to the text by setting the callback_function argument to your function. When the callback function is executed, the code expects and checks that the callback function accepts two arguments the first being the address of the associated hook and the second being the value of the reply See example below.

def test_callback(address, value):
	print "Callback function triggered by {address}!".format(address=address)
	print "Value was: " + value

ps.text("This is a text with a callback function!", callback=test_callback)

The receiver of the text will get the following message:

This is a text with a callback function!
Reply with identifier 1234 followed by a ":"

To which they can reply:

1234: Amazing

The callback function once the check_tracked() function finds the correct email will then print:

Callback function triggered by [email protected]!
Value was: Amazing

Additional settings such as the window time, delimiter and identifier length can be configured when you initialize the server object by setting the optional arguments window, delimiter and identifier_length repsectively.

Acknowledgements

Referenced https://www.digitaltrends.com/mobile/how-to-send-e-mail-to-sms-text/ for emails for each US carrier in self.carriers

Referenced https://yuji.wordpress.com/2011/06/22/python-imaplib-imap-example-with-gmail/ for how to process email_data coming back from imaplib in check_email()

Contributing

Pull requests and contributions are welcomed!

Support

For any questions or concerns, please create an issue or contact me.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].