How to return Gammu Python SendSMS function Sent Status?

1.9k views Asked by At

Hi and thanks for taking the time to help.

I'm currently using the following code

#!/usr/bin/env python
# Sample script to show how to send SMS

import gammu
import sys


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

message = {
    'Text': 'python-gammu testing message',
    'SMSC': {'Location': 1},
    'Number': '+584126555508',
}

# Actually send the message
sm.SendSMS(message)

It works fine, But how can i be sure that the SendSMS Function really sent the message...

for example: sent, unsent as a result from the SendSMS function return value.

Thanks for your answers in advance.

1

There are 1 answers

0
Eddwin Paz On
try:
  # Send SMS if all is OK
  sm.SendSMS(message)
  print 'Success, SMS was Sent'

except gammu.GSMError:
    # Show error if message not sent
    print 'Error, SMS not Sent'