Fixed sendEmail method