Send SMS using Python Gammu

Gammu is a command line utility for controlling a phone (or modem) written in C. Gammu can be used for phone management software or maybe a SMS Gateway. Gammu can manage SMS, MMS, Phonebook, Calendar, phone’s file system and Call.

Today, i try to install Gammu and Python Gammu on Ubuntu 10.10 Maverick. Then, i write some code to send sms using command line.

#!/usr/bin/env python
import gammu
import sys

sm = gammu.StateMachine()
sm.ReadConfig()
sm.Init()

message = { 
'Text' : sys.argv[1], 
'SMSC': {'Location': 1}, 
'Number': sys.argv[2],
}

sm.SendSMS(message)

save it as sms.py,
To use this script, just type: python sms.py “message” “number-to”

đŸ™‚

5 thoughts on “Send SMS using Python Gammu

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.