mirror of
https://github.com/pothi/mikrotik-scripts.git
synced 2025-07-29 23:14:27 +02:00
Add new scripts - SMS to SMS and SMS to email
This commit is contained in:
parent
7dfdef45c3
commit
98f36b7472
2 changed files with 64 additions and 0 deletions
32
scripts/sms-to-email.rsc
Normal file
32
scripts/sms-to-email.rsc
Normal file
|
@ -0,0 +1,32 @@
|
||||||
|
# SMS to Email
|
||||||
|
|
||||||
|
# Source: https://forum.mikrotik.com/viewtopic.php?f=9&t=61068#p312202
|
||||||
|
|
||||||
|
# Note: The SMS is removed from the inbox after sent by Email and forwarded
|
||||||
|
# even if email and forward fail! So, test it often!
|
||||||
|
|
||||||
|
:global adminEmail
|
||||||
|
|
||||||
|
:local smsPhone
|
||||||
|
:local smsMessage
|
||||||
|
:local smsTimeStamp
|
||||||
|
|
||||||
|
/tool sms inbox
|
||||||
|
|
||||||
|
:foreach receivedSMS in=[find] do={
|
||||||
|
:set smsPhone [get $receivedSMS phone]
|
||||||
|
:set smsMessage [get $receivedSMS message]
|
||||||
|
:set smsTimeStamp [get $receivedSMS timestamp]
|
||||||
|
|
||||||
|
:log info "\nSMS Received From: $smsPhone on $smsTimeStamp Message: $smsMessage"
|
||||||
|
|
||||||
|
# Send Email to $adminEmail
|
||||||
|
:do {
|
||||||
|
/tool e-mail send to="$adminEmail" body="$smsMessage" \
|
||||||
|
subject="SMS from $smsPhone at $smsTimeStamp"
|
||||||
|
} on-error={ :log error "SMS to Email Failed." }
|
||||||
|
:delay 3s
|
||||||
|
|
||||||
|
# Let's remove the SMS!
|
||||||
|
remove $receivedSMS
|
||||||
|
}
|
32
scripts/sms-to-sms.rsc
Normal file
32
scripts/sms-to-sms.rsc
Normal file
|
@ -0,0 +1,32 @@
|
||||||
|
# SMS to SMS
|
||||||
|
|
||||||
|
# Limitation: It just forwards the SMS. It doesn't forward the senderPhoneNumber or timestamp of received SMS.
|
||||||
|
|
||||||
|
# Source: https://forum.mikrotik.com/viewtopic.php?f=9&t=61068#p312202
|
||||||
|
|
||||||
|
:global adminPh
|
||||||
|
:local smsForwardPh $adminPh
|
||||||
|
|
||||||
|
:local smsPhone
|
||||||
|
:local smsMessage
|
||||||
|
:local smsTimeStamp
|
||||||
|
|
||||||
|
/tool sms inbox
|
||||||
|
|
||||||
|
:foreach receivedSMS in=[find] do={
|
||||||
|
:set smsPhone [get $receivedSMS phone]
|
||||||
|
:set smsMessage [get $receivedSMS message]
|
||||||
|
:set smsTimeStamp [get $receivedSMS timestamp]
|
||||||
|
|
||||||
|
:log info "\nSMS Received From: $smsPhone on $smsTimeStamp Message: $smsMessage"
|
||||||
|
|
||||||
|
# Forward the SMS to $smsForwardPh, without $smsPhone and smsTimeStamp
|
||||||
|
:do {
|
||||||
|
/tool sms send lte1 phone-number=$smsForwardPh message=$smsMessage
|
||||||
|
} on-error={ :log error "SMS to SMS Failed." }
|
||||||
|
:delay 2s
|
||||||
|
|
||||||
|
# Let's NOT remove the SMS!
|
||||||
|
# Let the other script (SMS to Email) remove it, after sending the message with full details.
|
||||||
|
# remove $receivedSMS
|
||||||
|
}
|
Loading…
Add table
Add a link
Reference in a new issue