Originally, the best option when it comes to shaking hands among members of the opposite sex is that one avoids doing so; especially when there are any moral qualms about it.
In case, there is no fear of temptation, and at the same time shaking hands is a customary practice in a certain society or community, then one may get over with it. The issue is, by and large, judged by one’s conscience.
In this regard, Sheikh Ahmad Kutty said the following:
“This is one of those issues one should decide based on one’s conscience and the circumstances. It is best for us to avoid shaking hands with members of the opposite sex in case there are any moral qualms about it. It is best that we do what our conscience tells us; we can always explain our position later.
If, however, you are okay with it, and there is nothing to suggest a source of temptation, then you may just get over with it, especially in a society or group where it is a custom. The latter would be the case if we are dealing with societies where shaking hands with everyone, regardless of male and female differences, is customary.
It is in the last mentioned case that even some of the jurists of the early times considered shaking hands with females as permissible, provided there is no temptation factor involved. Imam Ibrahim An-Nakh`ie was of this view, as is reported from him.“