email when wireless client connect to routerboard

I am looking for a script that send me an email (port 25) as a wireless client connect on the router board.
Anyone have an idea?

If you give it ip by dhcp, keep short lease time and use lease script.

http://forum.mikrotik.com/t/beep-when-someone-connects-to-wi-fi/94311/1 :slight_smile: replace sound with send-mail and you’re done.

I want a script if the connect with the wireless interface.
I mean email when wireless registration detect a client.

Ok. Just an idea: regularly read and store the connected mac addresses from registration tab and check their changes for example each 10 seconds. You can implement exclusion list if you have some of them that you are not interested in or the opposite.

How to do this Jarda?

What script must i use

I don’t have such script. I just provided an idea how you can solve your requirements during my tram trip to office. Such script would need definitely some debugging and fine tuning that can’t be done on mobile. Sorry for that. Can’t give you more.

I want a script that sent a email to me if there is someone registered on the wireless interface.
On “wireless” “registration”
I hope I am clear.
Sorry for my bad Englisch

Nowbody :frowning:

There is my script.
It starts at a certain interval and checks the maс-addresses of the connected clients, comparing them with the set of “their”. If there is an unknown address in the list of connected clients, it generates a message and sends it by mail, writing the address to the global variable (which I clear every night in the scheduler) in order not to send emails when every script is called while another maс-address is in the list of connected devices (antispam)

#Скрипт для оповещения о левых устройствах в сети по вафле. Запускать с интервалом.
# Выборка всех маков подключенных сейчас к вафле
:local Founded false
:local es 
:local eb
:global maclist 
:foreach i in=[/interface wireless registration-table find] do={
# отладочный вывод
#:put [/interface wireless registration-table get $i value-name=mac-address]
# Присвоить переменной мак в в текущем прогоне цикла
:local RegisteredMAC [/interface wireless registration-table get $i value-name=mac-address]
#Проверить - если хотя бы один из них наш то всё норм - ничего не делать. Иначе это левый мак и о нем нужно сообщить.
:if ($RegisteredMAC = "some:your:own:mac:address" \ 
#...... This may be some another your macs
or $RegisteredMAC = "another:your:own:mac:address") do={ 
# мак свой. Ничего не делать.
#:log info ($dynamicMAC. " already filtered")
} else= { 
#МАК НЕ НАШ! Сообщить письмом!
# отладочный вывод
#:put "$RegisteredMAC - enemy"
# Тут счетчик для проверки наличия мака в списке что бы не отправлять при каждом вызове скрипта. Сбрасывать в полночь переменную.
:local cnt 0
:foreach i in $maclist do={
:if ($RegisteredMAC = $i) do={
:set cnt ($cnt+1);
} 
}
#:put $cnt
# Если счетчик равен 0 значит такого мака еще не было в списке - будем считать его новым. Иначе будем считать что уже оповестили в прошлый раз.
:if ($cnt = 0) do={
:set $maclist [:put ($maclist, $RegisteredMAC)];
:set $Founded true
:set es "!!!Unknown MAC found at $[/system clock get date] $[/system clock get time]!!! "
:set eb "Unknown MAC $RegisteredMAC have IP: $[/ip arp get [/ip arp find mac-address=$RegisteredMAC] address], Uptime: $[/interface wireless registration-table get $i value-name=uptime] and Signal-Strength: $[/interface wireless registration-table get $i value-name=signal-strength] \r\n$eb"
}
}
}

:if ($Founded=true) do={
#:put "$es\r\n$eb"; 
/tool e-mail send to="your@email.com" subject=$es body=$eb;
}

I apologize for the grammar, but English is not my native language.