Fixed js error when sending emails