I think you'll need an app to do this.
I use a combination of:
- Bulk Discounts to generate the discount codes
- Klaviyo for email marketing software to send based on conditions (example, any order, or if they order a certain product, or repeat customer, etc)
- JudgeMe for review app and automatically send discounts to people that leave reviews (or every customer too, if you wish)
I think most quality email marketing software + review apps have a bulk discount feature, you just generate the codes then upload them and then they handle the email part.