Skip to content

Instantly share code, notes, and snippets.

@MotionDesignStudio
Last active August 30, 2023 09:50
Show Gist options
  • Star 4 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save MotionDesignStudio/8589412 to your computer and use it in GitHub Desktop.
Save MotionDesignStudio/8589412 to your computer and use it in GitHub Desktop.
Mass Texting (SMS) Messaging Via Google Voice And Python
#!/usr/bin/env python
import sys
from googlevoice import Voice
from googlevoice.util import input
sys.dont_write_bytecode = True
username=str(sys.argv[1]).strip()
password=str(sys.argv[2]).strip()
phone_numbers=str(sys.argv[3]).strip()
the_message=str(sys.argv[4]).strip()
print "user name:" , username
print "password:" , password
print "phone_numbers:" , phone_numbers
print "the_message:" , the_message
voice = Voice()
voice.login(username, password)
def send_mass_text():
with open(phone_numbers, 'r') as inF:
for this_phone_number in inF:
voice.send_sms(this_phone_number, the_message)
send_mass_text ()
VERY IMPORTANT!!
The problem: Google does not like less secure applications to have access to your account. When these applications try to login additional verification steps are needed. A way to get pass this is to decrease the level of security by doing the following.
Log into the account you are tying to use at www.google.com/voice
Go here: https://www.google.com/settings/security/lesssecureapps Where it say "Access for less secure apps" select "Enable".
Go here: https://accounts.google.com/DisplayUnlockCaptcha and click on "Continue".
That solved it for me.
How to install.
Using the commandline type the following commands.
Install Python
sudo aptitude install python3.1
cd /tmp
Install Mercurial Source Code Manager
sudo aptitude install mercurial
Download The Python Google Voice Source
hg clone https://code.google.com/r/bwpayne-pygooglevoice-auth-fix/ pygooglevoice/
cd pygooglevoice
hg pull
hg update
Build And Install Python Google Voice
python setup.py install
Test Python Google Voice
$ gvoice -e yourname@gmail.com
Password:
gvoice> call
Outgoing number: 18004664411
Forwarding number: 19175555555
Calling...
You need two files for this to work in the same directory. The Python code and a list of phone numbers example “phone_numbers.txt”. This file is included in the download.
Create a file named "google_voice_sms.py" and store the code from below in it making it executable by doing the following.
chmod a+x google_voice_sms.py
Example Usage: ./google_voice_sms.py mygmailaccount@gmail.com mypassword phone_numbers.txt "Test SMS"
9175555555
19175555555
01119175555555
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment