adding missing email address for principal

fixes #8515 


I extracted the code part from #8734 which are unrelated.

@libasys Does this fix the reported stuff from #8515 ?
please change variable to a proper name $email - but more important: in case no email was set by the user we better don't add the property below