make email function reusable