Fixing bug with email sending

Fixed a bug with email sending