Moving email trim logic from FE to BE.