Fixed the mail feature

Fixed the issue caused by users in sub-groups for the mail feature.