Skip to main content

etext is a python module that lets you send text messages using email SMS gateways. Both SMS and MMS are supported.

Instalation

pip install etext

Sending SMS messages

from etext import send_sms_via_email

phone_number = "123-123-1234"
message = "hello world!"
provider = "T-Mobile"

sender_credentials = ("email@gmail.com", "email_password")

send_sms_via_email(
    phone_number, message, provider, sender_credentials, subject="sent using etext"
)

number: str - phone number to text

message: str - message to send

provider: str - phone provider/carrier click here to see the supported providers.

sender_credentials: tuple - email and password for SMTP server

subject: str = "sent using etext" - subject for the email header

smtp_server: str = "smtp.gmail.com" - smtp server to use (gmail is the default)

smtp_port: int = 465 - smtp port (465) is the default

note the use of the keyword argument 'subject', some SMS gateways need a message to be formatted as an email, this includes the use of a subject in the header. You can try experimenting with the gateway you are using to see if you need to include text in the subject. Otherwise, you can pass in an empty subject like so:

subject=""

by default the smtp client used to send emails is gmail's smtp server on port 465. However, if you want to use a different smtp server or port you can do that using the smtp_server and smtp_port keyword arguments like this:

send_sms_via_email(
    phone_number,
    message,
    provider,
    sender_credentials,
    smtp_server="some_smtp_server",
    smtp_port="502",
)

Sending MMS messages

from etext import send_mms_via_email

file_path = "/path/to/file/file.png"

mime_maintype = "image"
mime_subtype = "png"

# note that compared to the first example, this number is formatted differently
# etext removes any characters that are not digits in the number, so feel free
# to format numbers however you want
phone_number = "(123) 123-1234"

message = "hello world!"
provider = "T-Mobile"

sender_credentials = ("email@gmail.com", "email_password")

send_mms_via_email(
    phone_number,
    message,
    file_path,
    mime_maintype,
    mime_subtype,
    provider,
    sender_credentials,
)

This method has all of the same parameters as the SMS method but adds three more parameters.

file_path:str - the file path of the file to send in the message

mime_maintype:str - the mime main type

mime_subtype:str - the mime sub type

here is a resource containing common mime types

the format corresponds like this: mime_maintype/mime_subtype. As an example, to send a pdf file via MMS, which has the following MIME type: application/pdf, we could use these main and subtypes:

mime_maintype = "application"
mime_subtype = "pdf"

More

If you are using etext with Gmail, you should set up an app password for use with etext. You can do that by clicking here.

Metadata

Release files for etext 0.0.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for etext 0.0.1
File Size Uploaded
etext-0.0.1.tar.gz 4.9 kB Details

Release files / etext-0.0.1.tar.gz

Download URL etext-0.0.1.tar.gz
Size 4.9 kB
Tags Source
SHA-256 checksum
How to use checksums
d8d02c7c1b5976026fcc2fdfa6a6f6d8caa9442b72e11082c217bf714af2daa1
BLAKE2b-256 checksum
How to use checksums
9f79b7a4daa62e84b05345f672e3a8bde7ccb60ed05674cfb0b91c1bbaf757ea
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.3.0 pkginfo/1.6.1 requests/2.25.1 setuptools/54.1.1 requests-toolbelt/0.9.1 tqdm/4.56.0 CPython/3.9.2

Release history Release notifications | RSS feed

This release

0.0.1 This release

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page