add email middleware