Community discussions

 
User avatar
techguy79
Frequent Visitor
Frequent Visitor
Topic Author
Posts: 66
Joined: Tue Mar 24, 2009 10:34 pm
Contact:

netwatch script compose email to multiple recipients?

Tue Mar 30, 2010 5:13 pm

Hello I'm trying to alter our existing netwatch on down event script to simply send an email to 5 recipients.
I've tried using a comma and or semi colon to separate each recipient.
Im using ROS v 3.30 Here's my existing script code copied from netwatch down event window in winbox.

/tool e-mail send \
to=abc@mycompany.com, michael\
.manns@gmail.com
from=KCMT@foresitewireless.com \ subject=("Room 206 AP is down") \

The first email address i altered to prevent webcrawlers from adding our support email.
the second email address is my personal account which im using strictly for testing.

When I try either email addresses by themselves it works by when i try adding any extra recipients it stops sending period.
I'm sure there is probably some syntax I'm missing for this to work .
Community please advise
 
SurferTim
Forum Guru
Forum Guru
Posts: 4637
Joined: Mon Jan 07, 2008 10:31 pm
Location: Miramar Beach, Florida

Re: netwatch script compose email to multiple recipients?

Tue Mar 30, 2010 6:32 pm

Did you try this?
/tool e-mail send \
to=abc@mycompany.com \
from=KCMT@foresitewireless.com \
subject=("Room 206 AP is down")

/tool e-mail send \
to=michael.manns@myemailserver.com \
from=KCMT@foresitewireless.com \
subject=("Room 206 AP is down")
ADD: Edited for the spambots.
 
User avatar
techguy79
Frequent Visitor
Frequent Visitor
Topic Author
Posts: 66
Joined: Tue Mar 24, 2009 10:34 pm
Contact:

Re: netwatch script compose email to multiple recipients?

Tue Mar 30, 2010 6:43 pm

that works too bad no way to consolidate but if it works sweet.
thanks surfer tim i guess i really should try to Keep It Simple Stupid
 
dssmiktik
Forum Veteran
Forum Veteran
Posts: 732
Joined: Fri Aug 17, 2007 8:42 am

Re: netwatch script compose email to multiple recipients?

Tue Mar 30, 2010 10:27 pm

Here is a more expandable / flexible approach you could try:
:local recipients { "abc@mycompany.com", \
                         "michael.manns@gmail.com", \
                         "another.email@domain.com" }

:local subject "Room 206 AP is down"

:foreach r in=[:toarray $recipients] do={
   :put ("Sending email to " . [:tostr $r])
   /tool e-mail send to=[:tostr $r] subject=[:tostr $subject]
}
As you need to add more recipients, just add their email to the list. Also, in the case of v4.6 where the tls= parameter changed, this allows you to maintain a single '/tool e-mail' command syntax instead of many, making updates to the script very easy.

Hope this helps, just a bit of programming advise.
 
User avatar
techguy79
Frequent Visitor
Frequent Visitor
Topic Author
Posts: 66
Joined: Tue Mar 24, 2009 10:34 pm
Contact:

Re: netwatch script compose email to multiple recipients?

Wed Mar 31, 2010 3:55 pm

thank you for the info, Time for me to dissect the code you provided to try to understand the inner workings.
I'm driven to learn mikrotik api/scripting.
 
TerAnYu
newbie
Posts: 25
Joined: Sun Jun 20, 2010 1:46 pm
Location: Russia, Novosibirsk

Re: netwatch script compose email to multiple recipients?

Mon Jan 14, 2019 5:16 am

:local from "KCMT@foresitewireless.com"
:local recipients "\
abc@mycompany.com,\
michael.manns@gmail.com";
:local subject "$[/system identity get name] - Room 206 AP is down"
:local body "$subject\r\n"


:foreach r in=[:toarray $recipients] do={
:log info ("Sending email to $[/system clock get time] " . [tostr $r]);
/tool e-mail send to=[:tostr $r] from="$from" subject="$subject" body="$body";
};
ROS: 6.[latest]
 
User avatar
eworm
Member
Member
Posts: 392
Joined: Wed Oct 22, 2014 9:23 am
Location: Oberhausen, Germany
Contact:

Re: netwatch script compose email to multiple recipients?

Mon Jan 14, 2019 9:59 am

Simply use cc... That accepts several receipients.
/tool e-mail send \
to=abc@mycompany.com \
cc=michael.manns@gmail.com,another@gmail.com \
from=KCMT@foresitewireless.com \
 subject=("Room 206 AP is down")
Manage RouterOS scripts and extend your devices' functionality: RouterOS Scripts
 
User avatar
Jotne
Forum Guru
Forum Guru
Posts: 1303
Joined: Sat Dec 24, 2016 11:17 am
Location: jo.overland at gmail.com

Re: netwatch script compose email to multiple recipients?

Tue Jan 15, 2019 2:54 pm

Smart workaround.

Why you can add multiple recipients for for CC and TO is strange. In normal email you can send to as meny TO users you like.
Also you need at list on TO user, also strange. Only CC should be enough as well.
Here MT has some work to do.
 
How to use Splunk to monitor your MikroTik Router

MikroTik->Splunk
 

Who is online

Users browsing this forum: MSN [Bot] and 10 guests