Is it possible to automate Kali Linux to send me an email whenever a failed login attempt occurs?

I'm not sure how to get the system to send an email when no one is logged in or how to set a task...