1.16. sms

This module provides functionality for sending free SMS messages by emailing a carriers SMS gateway.

1.16.1. Data

CARRIERS[source]

A dictionary for mapping carrier names to SMS via email gateways.

DEFAULT_FROM_ADDRESS[source]

The default email address to use in the from field.

1.16.2. Functions

get_smtp_servers(domain)[source]

Get the SMTP servers for the specified domain by querying their MX records.

Parameters

domain (str) – The domain to look up the MX records for.

Returns

The smtp servers for the specified domain.

Return type

list

lookup_carrier_gateway(carrier)[source]

Lookup the SMS gateway for the specified carrier. Normalization on the carrier name does take place and if an invalid or unknown value is specified, None will be returned.

Parameters

carrier (str) – The name of the carrier to lookup.

Returns

The SMS gateway for the specified carrier.

Return type

str

send_sms(message_text, phone_number, carrier, from_address=None)[source]

Send an SMS message by emailing the carriers SMS gateway. This method requires no money however some networks are blocked by the carriers due to being flagged for spam which can cause issues.

Parameters
  • message_text (str) – The message to send.

  • phone_number (str) – The phone number to send the SMS to.

  • carrier (str) – The cellular carrier that the phone number belongs to.

  • from_address (str) – The optional address to display in the ‘from’ field of the SMS.

Returns

This returns the status of the sent messsage.

Return type

bool