care.utils.sms.utils module

get_sms_content(template_path: str, context: dict) str
initialize_backend(backend_name: str | None = None, fail_silently: bool = False, **kwargs) SmsBackendBase

Load and configure an SMS backend.

Parameters:
  • backend_name (Optional[str]) – The dotted path to the backend class. If None, the default backend from settings is used.

  • fail_silently (bool) – Whether to handle exceptions quietly. Defaults to False.

Returns:

An initialized instance of the specified SMS backend.

Return type:

SmsBackendBase

send_text_message(content: str = '', sender: str | None = None, recipients: str | list[str] | None = None, fail_silently: bool = False, backend_instance: type[SmsBackendBase] | None = None) int

Send a single SMS message to one or more recipients.

Parameters:
  • content (str) – The message content to be sent. Defaults to an empty string.

  • sender (Optional[str]) – The sender’s phone number. Defaults to None.

  • recipients (Union[str, List[str], None]) – A single recipient or a list of recipients. Defaults to None.

  • fail_silently (bool) – Whether to suppress exceptions during sending. Defaults to False.

  • backend_instance (Optional[SmsBackendBase]) – A pre-configured SMS backend instance. Defaults to None.

Returns:

The number of messages successfully sent.

Return type:

int

get_sms_backend(backend_name: str | None = None, fail_silently: bool = False, **kwargs) SmsBackendBase

Load and return an SMS backend instance.

Parameters:
  • backend_name (Optional[str]) – The dotted path to the backend class. If None, the default backend from settings is used.

  • fail_silently (bool) – Whether to suppress exceptions quietly. Defaults to False.

  • **kwargs – Additional arguments passed to the backend constructor.

Returns:

An initialized instance of the specified SMS backend.

Return type:

SmsBackendBase