In our setup (based on yunohost) the profile.email field could be either a string (and that was properly handled) or an array. This code adds support for the case where it is an array.