A simple Python module to send text messages
Project description
send_text
A simple Python module to send text messages. Using this, it's possible to connect to an email and send a text message with it.
Some of the data in the text messages sent might be changed, and this is most likely an issue with the recipient's carrier or mobile OS. Sometimes, trailing newlines are cut off, or the filenames of images/videos aren't the same. It's also not possible to send .gif
files using this module. It is possible to send .mp4
files, however, so converting a .gif
to a(n) .mp4
and sending that is possible.
This module is available under the MIT license. See LICENSE for more information.
Do not expect this to be updated frequently.
Usage
First, run the command python -m pip install send_text
to install the module. No dependencies, outside of modules that come with Python by default, are required for this module. Shown below is the ideal way to use this module.
import send_text
with send_text.Sender("johnsmith@gmail.com", "password123", "smtp.gmail.com", 587) as sender:
sender.text("1234567890@mms.att.net", "I sent this text message using the send_text module!")
sender.text_image("1234567890@mms.att.net", "/path/to/image.png")
sender.text_video("1234567890@mms.att.net", "/path/to/video.mp4")
send_text.Sender
takes 4 arguments: an email, its password, the SMTP server of the email's domain, and the port to be used to connect to said SMTP server. It's possible to omit the last 2 arguments when creating a Sender, but it is not recommended. If they are omitted, the program will try to find that data by itself; however, the program can only find data for some of the most popular email domains, such as gmail.com and outlook.com.
Sender.text
, Sender.text_image
, and Sender.text_video
each take 2–3 arguments. The first argument is the phone number of the recipient. Ideally, it contains the MMS gateway domain as well (Ex: "1234567890@vzwpix" for Verizon). If the MMS gateway domain isn't there, the format should be "1234567890" (as a str; NOT an int). Additionally, the 3rd argument (carrier) must be included if the MMS gateway domain isn't in the number. It's case-insensitive, so there's no difference between "Verizon" and "verizon". Note that even if you include the carrier, the program might still fail; only some of the most popular carriers in the US are supported (e.g. Verizon, AT&T, T-Mobile).
The second argument of these functions all differ. In Sender.text
, the second argument is the message to be sent. In Sender.text_image
and Sender.text_video
, the second argument is a path to the image/video to be used.
If, for some reason, you do not want to use the with statement, the code below also works.
import send_text
sender = send_text.Sender("johnsmith@gmail.com", "password123", "smtp.gmail.com", 587)
sender.start()
try:
sender.text("1234567890@mms.att.net", "I sent this text message using the send_text module!")
sender.text_image("1234567890@mms.att.net", "/path/to/image.png")
sender.text_video("1234567890@mms.att.net", "/path/to/video.mp4")
finally:
sender.quit()
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file send_text-1.0.1.tar.gz
.
File metadata
- Download URL: send_text-1.0.1.tar.gz
- Upload date:
- Size: 6.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.4.1 importlib_metadata/3.7.3 pkginfo/1.7.0 requests/2.22.0 requests-toolbelt/0.9.1 tqdm/4.54.1 CPython/3.7.3
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6573e9f5457ca2e5cdbc6a735c2b6bd2c67d57ca04aa67f5493bd1d528cc19d9 |
|
MD5 | 1ca77b3daa6eb3a426282cf7d1536786 |
|
BLAKE2b-256 | 17e1d853ec3593116b4f43f3f110cd0f2d74cad148f0c61f7205c1aee1d6187f |
File details
Details for the file send_text-1.0.1-py3-none-any.whl
.
File metadata
- Download URL: send_text-1.0.1-py3-none-any.whl
- Upload date:
- Size: 7.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.4.1 importlib_metadata/3.7.3 pkginfo/1.7.0 requests/2.22.0 requests-toolbelt/0.9.1 tqdm/4.54.1 CPython/3.7.3
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | bad995226729f9786f2409ec36a8b2d4f4c4ca04eededf2b1cf59f256f103602 |
|
MD5 | d44d1bd5585e42c0117fddc5d347e432 |
|
BLAKE2b-256 | c247bf4c466da85c03425916d6add7ce8c2f7db3c11945d29666b6e0d29e36fb |