Is there any built in functionality to Password/Passcode protect/lock the mail app specifically? If there is no such feature out of box from Mac operating system, is there any third party app that can be used to achieve this?
The way I want it to function is, when I open the Mac Mail app, it should ask me Password/Passcode to unlock the app. The session should continue as long as Mac mail is open. It should ask the password again when I quit the app and relaunch it again.
sometimes I hand over my Mac to friends and I don’t want anyone to go over my mail accounts setup in my Mac. As the time duration is not very long when I hand over my Mac, it is not worth to create a separate users for each of my friend and then restrict them not to access specific app.
—–
Anant A Agavekar
There's nothing like that in macOS. Instead, the idea is you password protect your entire account. Only you should have access to your account. Password-protecting just an app wouldn't help much as the data is still there on your drive for anyone with Finder access to get to.
If your goal is to give your Mac to a friend to use, never give them access to your account. If you must do that, create a second account. Switch to that by using Fast User Switching. That works very quickly. That's the only secure way. Make sure they don't know your password (no one else should know your password) and make sure this second "other person" account is a Standard account, not an Admin account.
This will not only prevent them from peeping at your email or other data, but will stop them from looking at your files, deleting files, messing with them, changing your settings, or causing other problems. Even if someone doesn't intend to do that, a non-cautious user could accidentally change something that will cause problems.
So to be clear, my advice is: Never let someone else use your computer. If you have to break that rule, never give them access to your account but have another non-admin account they can use temporarily.
Gary's advice is sound - if you loan out your computer, or more specifically your computer account then you have already opened up everything to your friends.
You don't need to create a separate account for each user - just make a "Guest" account as a Standard User. There's no reason that they can't share that account as you effectively have been sharing your account with everyone if you just hand them your Mac