How to send confirmation email with conditions?