Skip to main content

Send sms and mms text messages for free using email

Project description

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.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

etext-0.0.1.tar.gz (4.9 kB view details)

Uploaded Source

File details

Details for the file etext-0.0.1.tar.gz.

File metadata

  • Download URL: etext-0.0.1.tar.gz
  • Upload date:
  • Size: 4.9 kB
  • Tags: Source
  • Uploaded using 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

File hashes

Hashes for etext-0.0.1.tar.gz
Algorithm Hash digest
SHA256 d8d02c7c1b5976026fcc2fdfa6a6f6d8caa9442b72e11082c217bf714af2daa1
MD5 e45d04f075dda541ad54f118d8e0ca46
BLAKE2b-256 9f79b7a4daa62e84b05345f672e3a8bde7ccb60ed05674cfb0b91c1bbaf757ea

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page