Skip to main content

A simple API to send SMS messages.

Project description

https://coveralls.io/repos/github/stefanfoulis/django-sendsms/badge.svg?branch=master https://travis-ci.org/stefanfoulis/django-sendsms.svg?branch=master https://badge.fury.io/py/django-sendsms.svg

A simple api to send SMS messages with django. The api is structured the same way as Django’s own email api.

Installation

pip install django-sendsms

Configure the SENDSMS_BACKEND (defaults to 'sendsms.backends.console.SmsBackend'):

SENDSMS_BACKEND = 'myapp.mysmsbackend.SmsBackend'

Basic usage

Sending SMSs is like sending emails:

from sendsms import api
api.send_sms(body='I can haz txt', from_phone='+41791111111', to=['+41791234567'])

You can also make instances of SmsMessage:

from sendsms.message import SmsMessage
message = SmsMessage(body='lolcats make me hungry', from_phone='+41791111111', to=['+41791234567'])
message.send()

Custom backends

Creating custom SmsBackend s:

from sendsms.backends.base import BaseSmsBackend
import some.sms.delivery.api

class AwesomeSmsBackend(BaseSmsBackend):
    def send_messages(self, messages):
        for message in messages:
            for to in message.to:
                try:
                    some.sms.delivery.api.send(
                        message=message.body,
                        from_phone=message.from_phone,
                        to_phone=to,
                        flashing=message.flash
                    )
                except:
                    if not self.fail_silently:
                        raise

Then all you need to do is reference your backend in the SENDSMS_BACKEND setting.

Running tests

python setup.py test

Or better, install and run “tox”.

Contributing

Pull requests are very welcome. Please make sure code is formatted using black and isort.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

django-sendsms-0.4.tar.gz (15.7 kB view details)

Uploaded Source

File details

Details for the file django-sendsms-0.4.tar.gz.

File metadata

  • Download URL: django-sendsms-0.4.tar.gz
  • Upload date:
  • Size: 15.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.14.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/40.7.0 requests-toolbelt/0.8.0 tqdm/4.30.0 CPython/3.6.7

File hashes

Hashes for django-sendsms-0.4.tar.gz
Algorithm Hash digest
SHA256 8558883e5f9fe7cf6785674c86bc5f93c979adf4e7719eacf181965dac990312
MD5 173022c0f61718642ecfd1f2e0744906
BLAKE2b-256 fd4f29127fc0bfc6e8ddfa46bd89d1cd67abed5635f92afeeb18f67dbfd63cea

See more details on using hashes here.

Provenance

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page