Updated email sending function