This shows you the differences between two versions of the page.
Last revision | |||
— | sdk:scripts:sms-to-email [2015/05/05 15:04] – external edit 127.0.0.1 | ||
---|---|---|---|
Line 1: | Line 1: | ||
+ | ====== SDK Script sms-to-email.are ====== | ||
+ | <code c sms-to-email.are> | ||
+ | /* DESC: This script will forward incoming SMS messages to a given E-mail address. | ||
+ | * Copyright (C) 2012 NetModule AG, Switzerland | ||
+ | */ | ||
+ | |||
+ | if (argc < 1 || strlen(argv[1]) == 0) { | ||
+ | printf(" | ||
+ | exit(1); | ||
+ | } | ||
+ | |||
+ | rcpt = argv[1]; | ||
+ | |||
+ | while(1) { | ||
+ | msgs = nb_sms_list(); | ||
+ | nr_msgs = length(msgs); | ||
+ | |||
+ | if (nr_msgs == 0) { | ||
+ | sleep(10); | ||
+ | continue; | ||
+ | } | ||
+ | |||
+ | for (i=0; i< | ||
+ | msg = nb_sms_retrieve(msgs[i]); | ||
+ | if (!msg) continue; | ||
+ | |||
+ | nb_syslog(" | ||
+ | i, nr_msgs, msgs[i]); | ||
+ | |||
+ | subject = "SMS received"; | ||
+ | sprintf(body, | ||
+ | |||
+ | if (nb_email_send(rcpt, | ||
+ | printf(" | ||
+ | } else { | ||
+ | printf(" | ||
+ | } | ||
+ | } | ||
+ | } | ||
+ | |||
+ | exit(0); | ||
+ | |||
+ | </ | ||