How to conditionally send emails?