Welcome to django-sendsms’s documentation!

Contents:

Usage example.

TODO

API Reference

General functions:

sendsms.api.get_connection(path=None, fail_silently=False, **kwargs)

Load an sms backend and return an instance of it.

Parameters:
  • path (string) – backend python path. Default: sendsms.backends.console.SmsBackend
  • fail_silently (bool) – Flag to not throw exceptions on error. Default: False
Returns:

backend class instance.

Return type:

BaseSmsBackend subclass

sendsms.api.send_mass_sms(datatuple, fail_silently=False, auth_user=None, auth_password=None, connection=None)

Given a datatuple of (message, from_phone, to, flash), sends each message to each recipient list.

Returns:the number of SMSs sent.
sendsms.api.send_sms(body, from_phone, to, flash=False, fail_silently=False, auth_user=None, auth_password=None, connection=None)

Easy wrapper for send a single SMS to a recipient list.

Returns:the number of SMSs sent.

Available backends:

Base SmsBackend

class sendsms.backends.base.BaseSmsBackend(fail_silently=False, **kwargs)

Base class for sms backend implementations.

Subclasses must at least overwrite send_messages()

close()

Close a network connection

open()

Open a network connection.

This method can be overwritten by backend implementations to open a network connection. It’s up to the backend implementation to track the status of a network connection if it’s needed by the backend. This method can be called by applications to force a single network connection to be used when sending multiple SMSs.

The default implementation does nothing.

send_messages(messages)

Sends one or more SmsMessage objects and returns the number of messages sent

Dummy SmsBackend

Dummy sms backend that does nothing.

class sendsms.backends.dummy.SmsBackend(fail_silently=False, **kwargs)
send_messages(messages)

Console SmsBackend

SMS backend that writes messages to console instead of sending them.

This is a total ripoff of django.core.mail.backends.console

class sendsms.backends.console.SmsBackend(*args, **kwargs)
send_messages(messages)

Write all messages to the stream in a thread-safe way.

sendsms.backends.console.render_message(message)

Locmem SmsBackend

Backend for test environment.

class sendsms.backends.locmem.SmsBackend(*args, **kwargs)

A sms backend for use during test sessions.

The test connection stores messages in a dummy outbox, rather than sending them out on the wire. The dummy outbox is accessible through the outbox instance attribute.

send_messages(messages)

Redirect messages to the dummy outbox

Twilio SmsBackend

SmsPubli SmsBackend

SmsPubli sms gateway backend. (http://www.smspubli.com)

Configuration example.

Modify your settings.py:

SMSPUBLI_USERNAME = 'yourusername'
SMSPUBLI_PASSWORD = 'mysecretpassword'
SMSPUBLI_ALLOW_LONG_SMS = True # or False
INSTALLED_APPS += ['sendsms']

Usage:

from sendsms.message import SmsMessage
message = SmsMessage(
    body = 'my 160 chars sms',
    from_phone = '111111111',
    to = ['222222222']
)
message.send()
class sendsms.backends.smspubli.SmsBackend(fail_silently=False, **kwargs)

SMS Backend smspubli.com provider.

The methods “get_xxxxxx” serve to facilitate the inheritance. Thus if a private project in the access data are dynamic, and are stored in the database. A child class overrides the method “get_xxxx” to return data stored in the database.

get_password()
get_username()
send_messages(messages)

Send messages.

Parameters:messages (list) – List of SmsMessage instences.
Returns:number of messages seded succesful.
Return type:int

Esendex SmsBackend

Esendex sms gateway backend. (http://www.esendex.es/)

Configuration example.

Modify your settings.py:

ESENDEX_USERNAME = 'yourusername'
ESENDEX_PASSWORD = 'mysecretpassword'
ESENDEX_ACCOUNT = 'account-key-provided-by-esendex'
ESENDEX_SANDBOX = False # True if yo like test first
INSTALLED_APPS += ['sendsms']

Usage:

from sendsms.message import SmsMessage
message = SmsMessage(
    body = 'my 160 chars sms',
    from_phone = '111111111',
    to = ['222222222']
)
message.send()
class sendsms.backends.esendex.SmsBackend(fail_silently=False, **kwargs)

SMS Backend for esendex.es provider.

The methods “get_xxxxxx” serve to facilitate the inheritance. Thus if a private project in the access data are dynamic, and are stored in the database. A child class overrides the method “get_xxxx” to return data stored in the database.

get_account()
get_password()
get_username()
send_messages(messages)

Send messages.

Parameters:messages (list) – List of SmsMessage instences.
Returns:number of messages seded succesful.
Return type:int

Indices and tables