Skip to content

Instantly share code, notes, and snippets.

@alexle
Created May 5, 2011 15:51
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save alexle/957293 to your computer and use it in GitHub Desktop.
Save alexle/957293 to your computer and use it in GitHub Desktop.
Send SMS text message with python
import smtplib
# Use sms gateway provided by mobile carrier:
# at&t: number@mms.att.net
# t-mobile: number@tmomail.net
# verizon: number@vtext.com
# sprint: number@page.nextel.com
server = smtplib.SMTP( "smtp.gmail.com", 587 )
server.ehlo()
server.starttls()
server.ehlo()
server.login( '<gmail_address>', '<gmail_password>' )
server.sendmail( '<from>', '<number>@tmomail.net', 'Hello!' )
@martialguitarist21
Copy link

note: gmail may block your sign in attempt since this is considered "less secure" by google. You can enable access for less secure apps in your account settings (see link below). So if line 13 throws an error, go to the link and read what you have to do. Then it should work.

https://support.google.com/accounts/answer/6010255

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