This is short and sweet. Say you want to get an email message anytime someone logs in to a user account on your server. Simply install the mailx package (yum install mailx), and then edit the user’s .bash_profile file in their home directory, adding the following line:
mailx -r $SOURCE_ADDRESS -s "$SUBJECT" $DESTINATION_ADDRESS < .email.msg
Obviously replace the variables with whatever you want for the sender’s address, subject line, and destination email address. Lastly, create a file in the user’s home dir called .email.msg (don’t forget the preceding period which will make it hidden). The contents of this file will be the body of your email message.
Short, sweet, and makes paranoid people like me very happy.