User login information-email notification for ssh root login

I have centos 7 and internet access. Now am want to email notification who can access a server (root & normal user)kindly suggest with me. How to write a script. All server running on virtual server only.

Virtual server:AWS and Azure

I am struggling with this


First of all you have to configure mail service on your server and make sure mail server is working fine which means you are able to send mails from your server or not

Look at the below link for creating scripts for sending mail notifications

Dear Ragu,
Thanks for the support and valuable information.