Skip to content

Instantly share code, notes, and snippets.

@alexle
Last active December 1, 2023 01:01
Show Gist options
  • Save alexle/1294495 to your computer and use it in GitHub Desktop.
Save alexle/1294495 to your computer and use it in GitHub Desktop.
How to send a text message with python
# sms.py
# Sends sms message to any cell phone using gmail smtp gateway
# Written by Alex Le
import smtplib
# Use sms gateway provided by mobile carrier:
# at&t: [email protected]
# t-mobile: [email protected]
# verizon: [email protected]
# sprint: [email protected]
# Establish a secure session with gmail's outgoing SMTP server using your gmail account
server = smtplib.SMTP( "smtp.gmail.com", 587 )
server.starttls()
server.login( '<gmail_address>', '<gmail_password>' )
# Send text message through SMS gateway of destination number
server.sendmail( '<from>', '<number>@tmomail.net', '<msg>' )
@acamso
Copy link

acamso commented Apr 2, 2021

For those interested, here is an implementation with multiple carriers + and async support: https://bit.ly/send-txt-msg

@mcmullinboy15
Copy link

Do you guys know how to remove the subject when you send the text? Like the forward slashes? I just get / no subject / when I leave it blank

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment