Updated send email function