mirror of
https://github.com/pothi/mikrotik-lte-scripts.git
synced 2025-06-20 21:35:46 +02:00
replace deprecated do-on-error with onerror-do syntax
This commit is contained in:
parent
20a1812d1f
commit
4ab2ca4228
1 changed files with 15 additions and 3 deletions
|
@ -1,10 +1,19 @@
|
|||
# SMS to Email
|
||||
|
||||
# version: 2.0
|
||||
# change log
|
||||
# - date: 2025-06-03
|
||||
# - replace deprecated do-on-error with onerror-do syntax
|
||||
|
||||
# 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!
|
||||
|
||||
# use the following if email is not sent due to dns failure
|
||||
# see: https://forum.mikrotik.com/viewtopic.php?p=1146199
|
||||
# /ip dns static add name=[/tool/e-mail/get server] address=[:put [:resolve [/tool/e-mail/get server]]] comment="email server"
|
||||
|
||||
:global adminEmail
|
||||
:if ([:typeof $adminEmail] = "nothing" || $adminEmail = "") do={
|
||||
:log error "adminEmail is not defined or nil."; :error "Error: Check the log"; }
|
||||
|
@ -23,12 +32,15 @@
|
|||
:log info "\nSMS Received From: $smsPhone on $smsTimeStamp Message: $smsMessage"
|
||||
|
||||
# Send Email to $adminEmail
|
||||
:do {
|
||||
:onerror errName {
|
||||
/tool e-mail send to="$adminEmail" body="$smsMessage" \
|
||||
subject="SMS from $smsPhone at $smsTimeStamp"
|
||||
} on-error={ :log error "SMS to Email Failed." }
|
||||
:delay 3s
|
||||
} do={
|
||||
:log error "SMS to Email Failed."
|
||||
:error "SMS to Email Failed."
|
||||
}
|
||||
|
||||
:delay 3s
|
||||
# Let's remove the SMS!
|
||||
remove $receivedSMS
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue