Adding the email functionality

I have make an menu in which first option is to start and second is to stop the services

 echo "Please enter the appropriate choice for doing the operations"
        echo "
        1) STOP Services        
        2) START Services 
        
    case $choice in
        1)
            echo "*************Stopping Services**************"
            stopAll.sh
            ;;
        2)
            echo "*************Starting Services**************"
            startAll.sh
            ;;

now please advise I want to add the functionality of email also in it that is lets say if some one stop the services by pressing the 1 option then a mail should be launced with the subject that services are stopped and with the body also that services are stopped at that time when the option 1 is pressed , please advise how to customize and the add the functionality of email. :confused:

In such case i suggest that you create a mailing code and call it. To email you can use several ways from maix to uuencode please be more specific as to what exactly you wish to achiever.
The idea way in your scenario will be if my assumptions are correct
after your start and stop scripts add the below

cat <A_TEMP_FILE> | mail -s "Subject" user@dmoain.com

If you have multiple users and DL's create a variable

MY_DL="user@dmoain.com, user1@dmoain.com"

and use it in the above command.

Good Luck

Why don't you just add the mail command to each case option:

case $choice in
         1) echo "*************Stopping Services**************"
            stopAll.sh
            mail -s "service stopped" mail@domain.com
            ;;
         2) echo "*************Starting Services**************"
            startAll.sh
            mail -s "service started" mail@domain.com
            ;;

Thanks a lot , but I want that mail to be send to the users on their Gmail Account let say I have two accounts abcd1@gmail.com and abcd2@gmail.com so I want mail to be send to these two accounts so please advise how to send mail to these two accounts through shell script and what settings need to be configured like SMTP .:confused:

---------- Post updated at 07:38 PM ---------- Previous update was at 07:37 PM ----------

you can follow what RudiC do,
but instead of add one email address.
use an email value instead
like what saurabh.mishra say:
MY_EMAIL:"user@dmoain.com, user1@dmoain.com"

then

case $choice in
         1) echo "*************Stopping Services**************"
            stopAll.sh
            mail -s "service stopped" $MY_EMAIL
            ;;
         2) echo "*************Starting Services**************"
            startAll.sh
            mail -s "service started" $MY_EMAIL
            ;;