GithubHelp home page GithubHelp logo

katdom13 / etext Goto Github PK

View Code? Open in Web Editor NEW

This project forked from alfredosequeida/etext

0.0 0.0 0.0 9 KB

Send text messages (sms + mms) using Python for free via email.

License: MIT License

Python 100.00%

etext's Introduction

Click here to watch a video of how this works

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

Installation

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 protected]", "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 protected]", "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.

etext's People

Contributors

alfredosequeida avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.