# patrick fuller's blog

## Texting from a Computer in Python

21 May 2012

Here’s a script to send a text message in Python. It uses the standard library and is very straightforward. It utilizes the fact that most major carriers allow texting via email (ie. by SMTP, so nothing more is needed than an email account and a desired target.

In my work, I use it to tell me when my computational simulations are done running. Also, it can send to any phone number and can be put in an infinite loop; days of fun, right there.

import smtplib
from email.mime.text import MIMEText

# Message to be sent
message = MIMEText("Hello, texting!")

phone_number = ""

# Gmail to Verizon. Change here for different combinations.
phone_number += "@vtext.com"

# Format message to look like an email