aboutsummaryrefslogtreecommitdiffstats
path: root/sms-forward
diff options
context:
space:
mode:
authorGravatar Christian Hesse <mail@eworm.de>2018-08-06 14:37:28 +0200
committerGravatar Christian Hesse <mail@eworm.de>2018-08-06 14:37:28 +0200
commit1972fc32d0cdc7f1d3ba8047e16cac6ae5e7b5f6 (patch)
tree701db92dc1161b0a26c7951fd9853342c9b26120 /sms-forward
parent2ec96e9db4dddea7ea9aa34996395c445b20cb67 (diff)
rename forward-sms -> sms-forward
Diffstat (limited to 'sms-forward')
-rw-r--r--sms-forward29
1 files changed, 29 insertions, 0 deletions
diff --git a/sms-forward b/sms-forward
new file mode 100644
index 0000000..64b8355
--- /dev/null
+++ b/sms-forward
@@ -0,0 +1,29 @@
+# RouterOS script: sms-forward
+# Copyright (c) 2013-2018 Christian Hesse <mail@eworm.de>
+#
+# forward SMS to e-mail
+
+:global "identity";
+:global "email-general-to";
+:global "email-general-cc";
+
+# check mail server
+:if ([ / tool netwatch get [ find where comment=[ / tool e-mail get address ] ] status ] != "up") do={
+ :error "Mail server is not up.";
+}
+
+# forward SMS in a loop
+:foreach sms in=[ / tool sms inbox find ] do={
+ :local message [ / tool sms inbox get $sms message ];
+ :local phone [ / tool sms inbox get $sms phone ];
+ :local timestamp [ / tool sms inbox get $sms timestamp ];
+ :local type [ / tool sms inbox get $sms type ];
+ / tool e-mail send to=$"email-general-to" cc=$"email-general-cc" \
+ subject=("[" . $identity . "] SMS Forwarding") \
+ body=("A message was received by " . $identity . ":\n\n" . \
+ "Phone: " . $phone . "\n" . \
+ "Timestamp: " . $timestamp . "\n" . \
+ "Type: " . $type . "\n\n" . \
+ "Message:\n" . $message);
+ / tool sms inbox remove $sms;
+}