Changes to email function