A Django package for sending SMS using multiple backends.
Project description
Care SMS - Backend Configuration for Django Apps
Care SMS supports multiple SMS backends for sending messages. Each backend is designed for specific use cases like testing, development, or production. Here's how you can configure and use each backend in a Django project:
1. Setting Up the Backend
To configure an SMS backend in a Django app, add the SMS_BACKEND setting in your settings.py file.
Example:
# settings.py
SMS_BACKEND = 'sms.backends.<backend_module>.<BackendClass>'
2. Dummy Backend
The Dummy Backend does nothing with the messages and is useful for testing.
Configuration:
# settings.py
SMS_BACKEND = 'sms.backends.dummy_backend.DummyBackend'
Usage:
from sms import send_text_message
send_text_message('Test Message', 'Sender', ['Recipient'])
3. LocMem Backend
The LocMem Backend stores messages in an in-memory outbox, ideal for testing without external dependencies.
Configuration:
# settings.py
SMS_BACKEND = 'sms.backends.locmem_backend.LocMemBackend'
Accessing the Outbox:
from sms.backends.locmem_backend import outbox
print(outbox) # List of sent messages
Usage:
from sms import send_text_message
send_text_message('Test Message', 'Sender', ['Recipient'])
4. Console Backend
The Console Backend writes messages to the console or a custom stream. This backend is useful during development.
Configuration:
# settings.py
SMS_BACKEND = 'sms.backends.console_backend.ConsoleBackend'
Usage:
from sms import send_text_message
send_text_message('Test Message', 'Sender', ['Recipient'])
5. File-Based Backend
The File-Based Backend saves messages to files in a specified directory, useful for debugging or lightweight persistence.
Configuration:
# settings.py
SMS_BACKEND = 'sms.backends.file_backend.FileBackend'
SMS_FILE_PATH = '/path/to/log/directory'
Usage:
from sms import send_text_message
send_text_message('Test Message', 'Sender', ['Recipient'])
6. MessageBird Backend
The MessageBird Backend sends SMS via the MessageBird API. Requires an API key.
Configuration:
# settings.py
SMS_BACKEND = 'sms.backends.messagebird_backend.MessageBirdBackend'
MESSAGEBIRD_ACCESS_KEY = 'your_messagebird_access_key'
Usage:
from sms import send_text_message
send_text_message('Test Message', 'Sender', ['Recipient'])
7. Twilio Backend
The Twilio Backend sends SMS via the Twilio API. Requires account credentials.
Configuration:
# settings.py
SMS_BACKEND = 'sms.backends.twilio_backend.TwilioBackend'
TWILIO_ACCOUNT_SID = 'your_account_sid'
TWILIO_AUTH_TOKEN = 'your_auth_token'
Usage:
from sms import send_text_message
send_text_message('Test Message', 'Sender', ['Recipient'])
8. AWS SNS Backend
The AWS SNS Backend sends SMS via AWS SNS. Requires AWS credentials and configuration.
Configuration:
# settings.py
SMS_BACKEND = 'sms.backends.aws_backend.SnsBackend'
AWS_SNS_REGION = 'your_region'
AWS_SNS_ACCESS_KEY_ID = 'your_access_key_id'
AWS_SNS_SECRET_ACCESS_KEY = 'your_secret_access_key'
AWS_SNS_SENDER_ID = 'your_sender_id'
AWS_SNS_SMS_TYPE = 'Transactional' # or 'Promotional'
Usage:
from sms import send_text_message
send_text_message('Test Message', 'Sender', ['Recipient'])
Sending SMS
Once configured, use the send_text_message function to send SMS:
from sms import send_text_message
send_text_message('Hello, World!', 'SenderID', ['+1234567890'])
This function uses the configured backend automatically.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file care-sms-1.0.0.tar.gz.
File metadata
- Download URL: care-sms-1.0.0.tar.gz
- Upload date:
- Size: 25.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.0.1 CPython/3.13.1
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
bb374f230dfabe6b7cc54f579d9ee678a38f22a2436ccda1311cb90d71062672
|
|
| MD5 |
1c10599e12c74b3c5b4fafacdab0d35a
|
|
| BLAKE2b-256 |
803eee328c345f6b48aa39ef4a4d8e9acfb0383460ef1a0ee500b6b43d18d1f5
|
File details
Details for the file care_sms-1.0.0-py3-none-any.whl.
File metadata
- Download URL: care_sms-1.0.0-py3-none-any.whl
- Upload date:
- Size: 15.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.0.1 CPython/3.13.1
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
40c7e2ebe9bfd54be4ce2f653fc7f174f8c9619fedeea08ff619747f58ed586d
|
|
| MD5 |
dd983a27fc629078b8bae2b1ab0e004b
|
|
| BLAKE2b-256 |
fdc25d266b11ed6e4cc491a0ea296408b58d3705df56305a1a9a88ffc4e6b72a
|