test if 'mail' is present before starting/sending mail

Signed-off-by: Édouard Lopez <dev+github@edouard-lopez.com>
typo

Signed-off-by: Édouard Lopez <dev+github@edouard-lopez.com>
refactoring: $appList -> $srvList

Signed-off-by: Édouard Lopez <dev+github@edouard-lopez.com>
create a monitor() function holding the loop

Signed-off-by: Édouard Lopez <dev+github@edouard-lopez.com>
move code to be logical

Signed-off-by: Édouard Lopez <dev+github@edouard-lopez.com>
add function description

Signed-off-by: Édouard Lopez <dev+github@edouard-lopez.com>